/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
python-ml-service
db/backup.sql
725 строк
20 KB
Dmitriy-Filatov
Реализация мгновенного поиска, рефакторинг вьюх и нормализация данных (март 2026)
05 мар 2026, 17:11
05 мар 2026, 17:11
e1f7dc5
Код
Авторство
О чём код?
-- -- PostgreSQL database dump -- -- Dumped from database version 14.5 (Homebrew) -- Dumped by pg_dump version 14.5 (Homebrew) SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; SET row_security = off; -- -- Name: ci_cyrillic; Type: COLLATION; Schema: public; Owner: dmitriy -- CREATE COLLATION public.ci_cyrillic (provider = icu, deterministic = false, locale = 'und-u-ks-level2'); ALTER COLLATION public.ci_cyrillic OWNER TO dmitriy; -- -- Name: citext; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public; -- -- Name: EXTENSION citext; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION citext IS 'data type for case-insensitive character strings'; SET default_tablespace = ''; SET default_table_access_method = heap; -- -- Name: action_text_rich_texts; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.action_text_rich_texts ( id bigint NOT NULL, name character varying NOT NULL, body text, record_type character varying NOT NULL, record_id bigint NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); ALTER TABLE public.action_text_rich_texts OWNER TO dmitriy; -- -- Name: action_text_rich_texts_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitriy -- CREATE SEQUENCE public.action_text_rich_texts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.action_text_rich_texts_id_seq OWNER TO dmitriy; -- -- Name: action_text_rich_texts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitriy -- ALTER SEQUENCE public.action_text_rich_texts_id_seq OWNED BY public.action_text_rich_texts.id; -- -- Name: active_storage_attachments; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.active_storage_attachments ( id bigint NOT NULL, name character varying NOT NULL, record_type character varying NOT NULL, record_id bigint NOT NULL, blob_id bigint NOT NULL, created_at timestamp(6) without time zone NOT NULL ); ALTER TABLE public.active_storage_attachments OWNER TO dmitriy; -- -- Name: active_storage_attachments_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitriy -- CREATE SEQUENCE public.active_storage_attachments_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.active_storage_attachments_id_seq OWNER TO dmitriy; -- -- Name: active_storage_attachments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitriy -- ALTER SEQUENCE public.active_storage_attachments_id_seq OWNED BY public.active_storage_attachments.id; -- -- Name: active_storage_blobs; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.active_storage_blobs ( id bigint NOT NULL, key character varying NOT NULL, filename character varying NOT NULL, content_type character varying, metadata text, service_name character varying NOT NULL, byte_size bigint NOT NULL, checksum character varying, created_at timestamp(6) without time zone NOT NULL ); ALTER TABLE public.active_storage_blobs OWNER TO dmitriy; -- -- Name: active_storage_blobs_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitriy -- CREATE SEQUENCE public.active_storage_blobs_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.active_storage_blobs_id_seq OWNER TO dmitriy; -- -- Name: active_storage_blobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitriy -- ALTER SEQUENCE public.active_storage_blobs_id_seq OWNED BY public.active_storage_blobs.id; -- -- Name: active_storage_variant_records; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.active_storage_variant_records ( id bigint NOT NULL, blob_id bigint NOT NULL, variation_digest character varying NOT NULL ); ALTER TABLE public.active_storage_variant_records OWNER TO dmitriy; -- -- Name: active_storage_variant_records_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitriy -- CREATE SEQUENCE public.active_storage_variant_records_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.active_storage_variant_records_id_seq OWNER TO dmitriy; -- -- Name: active_storage_variant_records_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitriy -- ALTER SEQUENCE public.active_storage_variant_records_id_seq OWNED BY public.active_storage_variant_records.id; -- -- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.ar_internal_metadata ( key character varying NOT NULL, value character varying, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); ALTER TABLE public.ar_internal_metadata OWNER TO dmitriy; -- -- Name: clients; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.clients ( id bigint NOT NULL, therapist_id bigint NOT NULL, name public.citext, email public.citext, phone character varying, notes text, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); ALTER TABLE public.clients OWNER TO dmitriy; -- -- Name: clients_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitriy -- CREATE SEQUENCE public.clients_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.clients_id_seq OWNER TO dmitriy; -- -- Name: clients_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitriy -- ALTER SEQUENCE public.clients_id_seq OWNED BY public.clients.id; -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.schema_migrations ( version character varying NOT NULL ); ALTER TABLE public.schema_migrations OWNER TO dmitriy; -- -- Name: sessions; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.sessions ( id bigint NOT NULL, client_id bigint NOT NULL, session_date date, topic character varying, notes text, homework text, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, therapist_id bigint NOT NULL ); ALTER TABLE public.sessions OWNER TO dmitriy; -- -- Name: sessions_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitriy -- CREATE SEQUENCE public.sessions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.sessions_id_seq OWNER TO dmitriy; -- -- Name: sessions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitriy -- ALTER SEQUENCE public.sessions_id_seq OWNED BY public.sessions.id; -- -- Name: therapists; Type: TABLE; Schema: public; Owner: dmitriy -- CREATE TABLE public.therapists ( id bigint NOT NULL, name character varying, email character varying, password_digest character varying, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); ALTER TABLE public.therapists OWNER TO dmitriy; -- -- Name: therapists_id_seq; Type: SEQUENCE; Schema: public; Owner: dmitriy -- CREATE SEQUENCE public.therapists_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.therapists_id_seq OWNER TO dmitriy; -- -- Name: therapists_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dmitriy -- ALTER SEQUENCE public.therapists_id_seq OWNED BY public.therapists.id; -- -- Name: action_text_rich_texts id; Type: DEFAULT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.action_text_rich_texts ALTER COLUMN id SET DEFAULT nextval('public.action_text_rich_texts_id_seq'::regclass); -- -- Name: active_storage_attachments id; Type: DEFAULT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_attachments ALTER COLUMN id SET DEFAULT nextval('public.active_storage_attachments_id_seq'::regclass); -- -- Name: active_storage_blobs id; Type: DEFAULT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_blobs ALTER COLUMN id SET DEFAULT nextval('public.active_storage_blobs_id_seq'::regclass); -- -- Name: active_storage_variant_records id; Type: DEFAULT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_variant_records ALTER COLUMN id SET DEFAULT nextval('public.active_storage_variant_records_id_seq'::regclass); -- -- Name: clients id; Type: DEFAULT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.clients ALTER COLUMN id SET DEFAULT nextval('public.clients_id_seq'::regclass); -- -- Name: sessions id; Type: DEFAULT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.sessions ALTER COLUMN id SET DEFAULT nextval('public.sessions_id_seq'::regclass); -- -- Name: therapists id; Type: DEFAULT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.therapists ALTER COLUMN id SET DEFAULT nextval('public.therapists_id_seq'::regclass); -- -- Data for Name: action_text_rich_texts; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.action_text_rich_texts (id, name, body, record_type, record_id, created_at, updated_at) FROM stdin; 16 notes Сбор данных о состоянии, согласование плана работы. Session 77 2026-02-23 15:32:41.640877 2026-02-23 15:32:41.640877 17 notes Выявление и анализ автоматических мыслей клиента. Session 78 2026-02-23 15:32:41.652535 2026-02-23 15:32:41.652535 18 notes Оценка текущей ситуации и планирование вмешательства. Session 79 2026-02-23 15:32:41.664044 2026-02-23 15:32:41.664044 \. -- -- Data for Name: active_storage_attachments; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.active_storage_attachments (id, name, record_type, record_id, blob_id, created_at) FROM stdin; \. -- -- Data for Name: active_storage_blobs; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.active_storage_blobs (id, key, filename, content_type, metadata, service_name, byte_size, checksum, created_at) FROM stdin; \. -- -- Data for Name: active_storage_variant_records; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.active_storage_variant_records (id, blob_id, variation_digest) FROM stdin; \. -- -- Data for Name: ar_internal_metadata; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.ar_internal_metadata (key, value, created_at, updated_at) FROM stdin; environment development 2026-02-10 01:16:30.651427 2026-02-10 01:16:30.651431 \. -- -- Data for Name: clients; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.clients (id, therapist_id, name, email, phone, notes, created_at, updated_at) FROM stdin; 42 32 N n@mail.ru +7 999 111-22-33 \N 2026-03-04 14:17:37.913363 2026-03-04 14:17:37.913363 43 32 N nn@mail.ru 999999999999 \N 2026-03-04 14:18:10.807787 2026-03-04 14:18:10.807787 44 32 ttt ttt@mail.ru yyy \N 2026-03-04 14:18:41.519001 2026-03-04 14:18:41.519001 38 32 Иван Иванов ivan@example.com +7 (999) 123-45-67 тратата 2026-02-23 15:32:41.613903 2026-03-05 08:09:46.490467 39 33 Ольга Петрова olga@example.com +7 (999) 765-43-21 \N 2026-02-23 15:32:41.621434 2026-02-23 15:32:41.621434 40 32 Я info@filatovda.ru +79175228664 \N 2026-03-04 13:23:41.653601 2026-03-04 13:23:41.653601 41 32 ЯЯ zakon9137@gmail.com +7 999 111-22-33 \N 2026-03-04 13:24:20.180876 2026-03-04 13:24:20.180876 \. -- -- Data for Name: schema_migrations; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.schema_migrations (version) FROM stdin; 20260210011524 20260210071456 20260210094427 20260211161153 20260218002321 20260218004416 20260219231935 20260222002706 20260222012612 20260222012613 20260305124030 \. -- -- Data for Name: sessions; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.sessions (id, client_id, session_date, topic, notes, homework, created_at, updated_at, therapist_id) FROM stdin; 77 38 2026-02-22 Первичная консультация \N \N 2026-02-23 15:32:41.638992 2026-02-23 15:32:41.642687 32 78 38 2026-02-23 Работа с убеждениями \N \N 2026-02-23 15:32:41.650971 2026-02-23 15:32:41.654137 32 79 39 2026-02-23 Диагностическая встреча \N \N 2026-02-23 15:32:41.662223 2026-02-23 15:32:41.665562 33 \. -- -- Data for Name: therapists; Type: TABLE DATA; Schema: public; Owner: dmitriy -- COPY public.therapists (id, name, email, password_digest, created_at, updated_at) FROM stdin; 32 Анна anna@example.com $2a$12$4RXdtqiEhP5piX2Owf5rOusPmeXqcQX/xHCD4c1hQQt6umFUxZova 2026-02-23 15:32:41.376491 2026-02-23 15:32:41.376491 33 Борис boris@example.com $2a$12$Fp/jw2POiavFMFErJHjv/.LOu6NjYOtDrhcc7TX3B2I8E4qfx2Aqq 2026-02-23 15:32:41.605389 2026-02-23 15:32:41.605389 34 I i@mail.ru $2a$12$pYJtOQyHt8j9ALyt.IWJDuOjq3HbpG1uVQpvieBHCF8NbbiCyzuK2 2026-02-25 12:42:13.893677 2026-02-25 12:42:13.893677 \. -- -- Name: action_text_rich_texts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitriy -- SELECT pg_catalog.setval('public.action_text_rich_texts_id_seq', 18, true); -- -- Name: active_storage_attachments_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitriy -- SELECT pg_catalog.setval('public.active_storage_attachments_id_seq', 1, false); -- -- Name: active_storage_blobs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitriy -- SELECT pg_catalog.setval('public.active_storage_blobs_id_seq', 1, false); -- -- Name: active_storage_variant_records_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitriy -- SELECT pg_catalog.setval('public.active_storage_variant_records_id_seq', 1, false); -- -- Name: clients_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitriy -- SELECT pg_catalog.setval('public.clients_id_seq', 44, true); -- -- Name: sessions_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitriy -- SELECT pg_catalog.setval('public.sessions_id_seq', 79, true); -- -- Name: therapists_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dmitriy -- SELECT pg_catalog.setval('public.therapists_id_seq', 34, true); -- -- Name: action_text_rich_texts action_text_rich_texts_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.action_text_rich_texts ADD CONSTRAINT action_text_rich_texts_pkey PRIMARY KEY (id); -- -- Name: active_storage_attachments active_storage_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_attachments ADD CONSTRAINT active_storage_attachments_pkey PRIMARY KEY (id); -- -- Name: active_storage_blobs active_storage_blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_blobs ADD CONSTRAINT active_storage_blobs_pkey PRIMARY KEY (id); -- -- Name: active_storage_variant_records active_storage_variant_records_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_variant_records ADD CONSTRAINT active_storage_variant_records_pkey PRIMARY KEY (id); -- -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.ar_internal_metadata ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); -- -- Name: clients clients_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.clients ADD CONSTRAINT clients_pkey PRIMARY KEY (id); -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- -- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.sessions ADD CONSTRAINT sessions_pkey PRIMARY KEY (id); -- -- Name: therapists therapists_pkey; Type: CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.therapists ADD CONSTRAINT therapists_pkey PRIMARY KEY (id); -- -- Name: index_action_text_rich_texts_uniqueness; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE UNIQUE INDEX index_action_text_rich_texts_uniqueness ON public.action_text_rich_texts USING btree (record_type, record_id, name); -- -- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE INDEX index_active_storage_attachments_on_blob_id ON public.active_storage_attachments USING btree (blob_id); -- -- Name: index_active_storage_attachments_uniqueness; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE UNIQUE INDEX index_active_storage_attachments_uniqueness ON public.active_storage_attachments USING btree (record_type, record_id, name, blob_id); -- -- Name: index_active_storage_blobs_on_key; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE UNIQUE INDEX index_active_storage_blobs_on_key ON public.active_storage_blobs USING btree (key); -- -- Name: index_active_storage_variant_records_uniqueness; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE UNIQUE INDEX index_active_storage_variant_records_uniqueness ON public.active_storage_variant_records USING btree (blob_id, variation_digest); -- -- Name: index_clients_on_email_and_therapist_id; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE UNIQUE INDEX index_clients_on_email_and_therapist_id ON public.clients USING btree (email, therapist_id); -- -- Name: index_clients_on_therapist_id; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE INDEX index_clients_on_therapist_id ON public.clients USING btree (therapist_id); -- -- Name: index_sessions_on_client_date_created; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE INDEX index_sessions_on_client_date_created ON public.sessions USING btree (client_id, session_date, created_at); -- -- Name: index_sessions_on_client_id; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE INDEX index_sessions_on_client_id ON public.sessions USING btree (client_id); -- -- Name: index_sessions_on_therapist_and_date; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE INDEX index_sessions_on_therapist_and_date ON public.sessions USING btree (therapist_id, session_date); -- -- Name: index_therapists_on_email; Type: INDEX; Schema: public; Owner: dmitriy -- CREATE UNIQUE INDEX index_therapists_on_email ON public.therapists USING btree (email); -- -- Name: sessions fk_rails_4b01dd9eb4; Type: FK CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.sessions ADD CONSTRAINT fk_rails_4b01dd9eb4 FOREIGN KEY (therapist_id) REFERENCES public.therapists(id); -- -- Name: clients fk_rails_821fe411eb; Type: FK CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.clients ADD CONSTRAINT fk_rails_821fe411eb FOREIGN KEY (therapist_id) REFERENCES public.therapists(id); -- -- Name: active_storage_variant_records fk_rails_993965df05; Type: FK CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_variant_records ADD CONSTRAINT fk_rails_993965df05 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); -- -- Name: sessions fk_rails_9e410b9855; Type: FK CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.sessions ADD CONSTRAINT fk_rails_9e410b9855 FOREIGN KEY (client_id) REFERENCES public.clients(id); -- -- Name: active_storage_attachments fk_rails_c3b3935057; Type: FK CONSTRAINT; Schema: public; Owner: dmitriy -- ALTER TABLE ONLY public.active_storage_attachments ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); -- -- PostgreSQL database dump complete --