From ca2ea919769351d7923d08812103edf3ded07358 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 13 Feb 2025 12:03:40 -0300 Subject: [PATCH] feat: add database service as dev dependency --- .devfiles/docker/docker-compose.dev.yaml | 29 + .env.example | 4 + .gitignore | 1 + .justfile | 12 + .../20250205190533_create_sources_table.sql | 13 + ...250206220324_create_logic_groups_table.sql | 15 + ...07152518_add_table_desambiguator_types.sql | 35 + .../20250207174953_add_table_entries.sql | 77 ++ db/schema.sql | 861 ++++++++++++++++++ 9 files changed, 1047 insertions(+) create mode 100644 .devfiles/docker/docker-compose.dev.yaml create mode 100644 .env.example create mode 100644 db/migrations/20250205190533_create_sources_table.sql create mode 100644 db/migrations/20250206220324_create_logic_groups_table.sql create mode 100644 db/migrations/20250207152518_add_table_desambiguator_types.sql create mode 100644 db/migrations/20250207174953_add_table_entries.sql create mode 100644 db/schema.sql diff --git a/.devfiles/docker/docker-compose.dev.yaml b/.devfiles/docker/docker-compose.dev.yaml new file mode 100644 index 0000000..ffe73f3 --- /dev/null +++ b/.devfiles/docker/docker-compose.dev.yaml @@ -0,0 +1,29 @@ +services: + db: + image: postgres:17-alpine + ports: + - 5432:5432 + environment: + POSTGRES_USER: ${CPD_DB_USER} + POSTGRES_PASSWORD: ${CPD_DB_PASSWORD} + POSTGRES_DB: ${CPD_DB_NAME} + + adminer: + image: ghcr.io/shyim/adminerevo:latest + ports: + - 8080:8080 + environment: + ADMINER_DEFAULT_DRIVER: psql + ADMINER_DEFAULT_SERVER: db + ADMINER_DEFAULT_USER: ${CPD_DB_USER} + ADMINER_DEFAULT_PASSWORD: ${CPD_DB_PASSWORD} + ADMINER_DEFAULT_DB: ${CPD_DB_NAME} + + dbmate: + image: ghcr.io/amacneil/dbmate + restart: no + command: ["--wait", "migrate"] + volumes: + - ${PWD}/db:/db + environment: + DATABASE_URL: postgres://${CPD_DB_USER}:${CPD_DB_PASSWORD}@db:5432/${CPD_DB_NAME}?sslmode=disable diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c3cd5a8 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +CPD_DB_HOST=localhost +CPD_DB_USER=postgres +CPD_DB_PASSWORD=postgres +CPD_DB_NAME=compendium diff --git a/.gitignore b/.gitignore index 56509c6..d44f2b5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ # Added by cargo /target +.env diff --git a/.justfile b/.justfile index f89f26a..589a424 100644 --- a/.justfile +++ b/.justfile @@ -1,5 +1,17 @@ # Repo management tasks mod repo ".devfiles/justfile" +set dotenv-load := true + +[private] +docker-compose +ARGS: + docker compose --file .devfiles/docker/docker-compose.dev.yaml --env-file .env --project-name compendium {{ARGS}} + +start-dev-services: (docker-compose "up --remove-orphans") + dev: cargo run + +migrate: (docker-compose "run dbmate migrate") + +rollback: (docker-compose "run dbmate rollback") diff --git a/db/migrations/20250205190533_create_sources_table.sql b/db/migrations/20250205190533_create_sources_table.sql new file mode 100644 index 0000000..36dac58 --- /dev/null +++ b/db/migrations/20250205190533_create_sources_table.sql @@ -0,0 +1,13 @@ +-- migrate:up +CREATE TABLE public.sources ( + id serial PRIMARY KEY, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone + ); + +-- migrate:down +DROP TABLE public.sources; diff --git a/db/migrations/20250206220324_create_logic_groups_table.sql b/db/migrations/20250206220324_create_logic_groups_table.sql new file mode 100644 index 0000000..2537c20 --- /dev/null +++ b/db/migrations/20250206220324_create_logic_groups_table.sql @@ -0,0 +1,15 @@ +-- migrate:up +CREATE TABLE public.logic_groups ( + id serial PRIMARY KEY, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + source_id int, + created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp WITH time zone, + deleted_at timestamp WITH time zone, + CONSTRAINT fk_source FOREIGN KEY (source_id) REFERENCES public.sources(id) +); + +-- migrate:down +DROP TABLE public.logic_groups; diff --git a/db/migrations/20250207152518_add_table_desambiguator_types.sql b/db/migrations/20250207152518_add_table_desambiguator_types.sql new file mode 100644 index 0000000..b311997 --- /dev/null +++ b/db/migrations/20250207152518_add_table_desambiguator_types.sql @@ -0,0 +1,35 @@ +-- migrate:up +CREATE TABLE public.desambiguator_types( + id serial PRIMARY KEY, + name varchar(15) NOT NULL, + input_type varchar(15) NOT NULL, + placeholder varchar(30), + created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp WITH time zone, + deleted_at timestamp WITH time zone +); + +INSERT INTO + public.desambiguator_types(name, input_type, placeholder) +VALUES + ('Text', 'text', 'XXX-XXX-XXX'), + ('Date', 'date', '2020-12-31'); + +ALTER TABLE + public.sources +ADD + COLUMN desambiguator_type_id int NOT NULL DEFAULT 1; + +ALTER TABLE + public.sources +ADD + CONSTRAINT fk_desambiguator_type FOREIGN KEY (desambiguator_type_id) REFERENCES public.desambiguator_types(id); + +-- migrate:down +ALTER TABLE + public.sources DROP CONSTRAINT fk_desambiguator_type; + +ALTER TABLE + public.sources DROP COLUMN desambiguator_type_id; + +DROP TABLE public.desambiguator_types; diff --git a/db/migrations/20250207174953_add_table_entries.sql b/db/migrations/20250207174953_add_table_entries.sql new file mode 100644 index 0000000..a0fc42e --- /dev/null +++ b/db/migrations/20250207174953_add_table_entries.sql @@ -0,0 +1,77 @@ +-- migrate:up +CREATE TABLE public.entries ( + id serial NOT NULL, + uid varchar NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp WITH time zone, + deleted_at timestamp WITH time zone, + PRIMARY KEY (id, created_at), + CONSTRAINT fk_logic_group FOREIGN KEY (logic_group_id) REFERENCES public.logic_groups(id) +) PARTITION BY RANGE (created_at); + +CREATE INDEX index_entries_uid ON ONLY public.entries USING btree (uid); + +CREATE SCHEMA entries_partitions; + +CREATE TABLE entries_partitions.e2020 PARTITION OF public.entries FOR +VALUES +FROM + ('2020-01-01') TO ('2021-01-01'); + +CREATE TABLE entries_partitions.e2021 PARTITION OF public.entries FOR +VALUES +FROM + ('2021-01-01') TO ('2022-01-01'); + +CREATE TABLE entries_partitions.e2022 PARTITION OF public.entries FOR +VALUES +FROM + ('2022-01-01') TO ('2023-01-01'); + +CREATE TABLE entries_partitions.e2023 PARTITION OF public.entries FOR +VALUES +FROM + ('2023-01-01') TO ('2024-01-01'); + +CREATE TABLE entries_partitions.e2024 PARTITION OF public.entries FOR +VALUES +FROM + ('2024-01-01') TO ('2025-01-01'); + +CREATE TABLE entries_partitions.e2025 PARTITION OF public.entries FOR +VALUES +FROM + ('2025-01-01') TO ('2026-01-01'); + +CREATE TABLE entries_partitions.e2026 PARTITION OF public.entries FOR +VALUES +FROM + ('2026-01-01') TO ('2027-01-01'); + +CREATE TABLE entries_partitions.e2027 PARTITION OF public.entries FOR +VALUES +FROM + ('2027-01-01') TO ('2028-01-01'); + +CREATE TABLE entries_partitions.e2028 PARTITION OF public.entries FOR +VALUES +FROM + ('2028-01-01') TO ('2029-01-01'); + +CREATE TABLE entries_partitions.e2029 PARTITION OF public.entries FOR +VALUES +FROM + ('2029-01-01') TO ('2030-01-01'); + +CREATE TABLE entries_partitions.e2030 PARTITION OF public.entries FOR +VALUES +FROM + ('2030-01-01') TO ('2031-01-01'); + +-- migrate:down +DROP TABLE public.entries; + +DROP schema entries_partitions; diff --git a/db/schema.sql b/db/schema.sql new file mode 100644 index 0000000..825bf15 --- /dev/null +++ b/db/schema.sql @@ -0,0 +1,861 @@ +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET transaction_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: entries_partitions; Type: SCHEMA; Schema: -; Owner: - +-- + +CREATE SCHEMA entries_partitions; + + +SET default_tablespace = ''; + +-- +-- Name: entries; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.entries ( + id integer NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +) +PARTITION BY RANGE (created_at); + + +-- +-- Name: entries_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.entries_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.entries_id_seq OWNED BY public.entries.id; + + +SET default_table_access_method = heap; + +-- +-- Name: e2020; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2020 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2021; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2021 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2022; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2022 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2023; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2023 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2024; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2024 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2025; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2025 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2026; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2026 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2027; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2027 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2028; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2028 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2029; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2029 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2030; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2030 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: desambiguator_types; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.desambiguator_types ( + id integer NOT NULL, + name character varying(15) NOT NULL, + input_type character varying(15) NOT NULL, + placeholder character varying(30), + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: desambiguator_types_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.desambiguator_types_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: desambiguator_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.desambiguator_types_id_seq OWNED BY public.desambiguator_types.id; + + +-- +-- Name: logic_groups; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.logic_groups ( + id integer NOT NULL, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + source_id integer, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: logic_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.logic_groups_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: logic_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.logic_groups_id_seq OWNED BY public.logic_groups.id; + + +-- +-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.schema_migrations ( + version character varying(128) NOT NULL +); + + +-- +-- Name: sources; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sources ( + id integer NOT NULL, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone, + desambiguator_type_id integer DEFAULT 1 NOT NULL +); + + +-- +-- Name: sources_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.sources_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: sources_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.sources_id_seq OWNED BY public.sources.id; + + +-- +-- Name: e2020; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2020 FOR VALUES FROM ('2020-01-01 00:00:00+00') TO ('2021-01-01 00:00:00+00'); + + +-- +-- Name: e2021; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2021 FOR VALUES FROM ('2021-01-01 00:00:00+00') TO ('2022-01-01 00:00:00+00'); + + +-- +-- Name: e2022; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2022 FOR VALUES FROM ('2022-01-01 00:00:00+00') TO ('2023-01-01 00:00:00+00'); + + +-- +-- Name: e2023; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2023 FOR VALUES FROM ('2023-01-01 00:00:00+00') TO ('2024-01-01 00:00:00+00'); + + +-- +-- Name: e2024; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2024 FOR VALUES FROM ('2024-01-01 00:00:00+00') TO ('2025-01-01 00:00:00+00'); + + +-- +-- Name: e2025; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2025 FOR VALUES FROM ('2025-01-01 00:00:00+00') TO ('2026-01-01 00:00:00+00'); + + +-- +-- Name: e2026; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2026 FOR VALUES FROM ('2026-01-01 00:00:00+00') TO ('2027-01-01 00:00:00+00'); + + +-- +-- Name: e2027; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2027 FOR VALUES FROM ('2027-01-01 00:00:00+00') TO ('2028-01-01 00:00:00+00'); + + +-- +-- Name: e2028; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2028 FOR VALUES FROM ('2028-01-01 00:00:00+00') TO ('2029-01-01 00:00:00+00'); + + +-- +-- Name: e2029; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2029 FOR VALUES FROM ('2029-01-01 00:00:00+00') TO ('2030-01-01 00:00:00+00'); + + +-- +-- Name: e2030; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2030 FOR VALUES FROM ('2030-01-01 00:00:00+00') TO ('2031-01-01 00:00:00+00'); + + +-- +-- Name: desambiguator_types id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.desambiguator_types ALTER COLUMN id SET DEFAULT nextval('public.desambiguator_types_id_seq'::regclass); + + +-- +-- Name: entries id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.entries ALTER COLUMN id SET DEFAULT nextval('public.entries_id_seq'::regclass); + + +-- +-- Name: logic_groups id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.logic_groups ALTER COLUMN id SET DEFAULT nextval('public.logic_groups_id_seq'::regclass); + + +-- +-- Name: sources id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sources ALTER COLUMN id SET DEFAULT nextval('public.sources_id_seq'::regclass); + + +-- +-- Name: entries entries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.entries + ADD CONSTRAINT entries_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2020 e2020_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2020 + ADD CONSTRAINT e2020_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2021 e2021_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2021 + ADD CONSTRAINT e2021_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2022 e2022_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2022 + ADD CONSTRAINT e2022_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2023 e2023_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2023 + ADD CONSTRAINT e2023_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2024 e2024_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2024 + ADD CONSTRAINT e2024_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2025 e2025_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2025 + ADD CONSTRAINT e2025_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2026 e2026_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2026 + ADD CONSTRAINT e2026_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2027 e2027_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2027 + ADD CONSTRAINT e2027_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2028 e2028_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2028 + ADD CONSTRAINT e2028_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2029 e2029_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2029 + ADD CONSTRAINT e2029_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2030 e2030_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2030 + ADD CONSTRAINT e2030_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: desambiguator_types desambiguator_types_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.desambiguator_types + ADD CONSTRAINT desambiguator_types_pkey PRIMARY KEY (id); + + +-- +-- Name: logic_groups logic_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.logic_groups + ADD CONSTRAINT logic_groups_pkey PRIMARY KEY (id); + + +-- +-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.schema_migrations + ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); + + +-- +-- Name: sources sources_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sources + ADD CONSTRAINT sources_pkey PRIMARY KEY (id); + + +-- +-- Name: index_entries_uid; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_entries_uid ON ONLY public.entries USING btree (uid); + + +-- +-- Name: e2020_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2020_uid_idx ON entries_partitions.e2020 USING btree (uid); + + +-- +-- Name: e2021_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2021_uid_idx ON entries_partitions.e2021 USING btree (uid); + + +-- +-- Name: e2022_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2022_uid_idx ON entries_partitions.e2022 USING btree (uid); + + +-- +-- Name: e2023_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2023_uid_idx ON entries_partitions.e2023 USING btree (uid); + + +-- +-- Name: e2024_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2024_uid_idx ON entries_partitions.e2024 USING btree (uid); + + +-- +-- Name: e2025_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2025_uid_idx ON entries_partitions.e2025 USING btree (uid); + + +-- +-- Name: e2026_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2026_uid_idx ON entries_partitions.e2026 USING btree (uid); + + +-- +-- Name: e2027_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2027_uid_idx ON entries_partitions.e2027 USING btree (uid); + + +-- +-- Name: e2028_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2028_uid_idx ON entries_partitions.e2028 USING btree (uid); + + +-- +-- Name: e2029_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2029_uid_idx ON entries_partitions.e2029 USING btree (uid); + + +-- +-- Name: e2030_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2030_uid_idx ON entries_partitions.e2030 USING btree (uid); + + +-- +-- Name: e2020_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2020_pkey; + + +-- +-- Name: e2020_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2020_uid_idx; + + +-- +-- Name: e2021_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2021_pkey; + + +-- +-- Name: e2021_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2021_uid_idx; + + +-- +-- Name: e2022_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2022_pkey; + + +-- +-- Name: e2022_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2022_uid_idx; + + +-- +-- Name: e2023_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2023_pkey; + + +-- +-- Name: e2023_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2023_uid_idx; + + +-- +-- Name: e2024_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2024_pkey; + + +-- +-- Name: e2024_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2024_uid_idx; + + +-- +-- Name: e2025_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2025_pkey; + + +-- +-- Name: e2025_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2025_uid_idx; + + +-- +-- Name: e2026_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2026_pkey; + + +-- +-- Name: e2026_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2026_uid_idx; + + +-- +-- Name: e2027_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2027_pkey; + + +-- +-- Name: e2027_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2027_uid_idx; + + +-- +-- Name: e2028_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2028_pkey; + + +-- +-- Name: e2028_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2028_uid_idx; + + +-- +-- Name: e2029_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2029_pkey; + + +-- +-- Name: e2029_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2029_uid_idx; + + +-- +-- Name: e2030_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2030_pkey; + + +-- +-- Name: e2030_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2030_uid_idx; + + +-- +-- Name: sources fk_desambiguator_type; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sources + ADD CONSTRAINT fk_desambiguator_type FOREIGN KEY (desambiguator_type_id) REFERENCES public.desambiguator_types(id); + + +-- +-- Name: entries fk_logic_group; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE public.entries + ADD CONSTRAINT fk_logic_group FOREIGN KEY (logic_group_id) REFERENCES public.logic_groups(id); + + +-- +-- Name: logic_groups fk_source; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.logic_groups + ADD CONSTRAINT fk_source FOREIGN KEY (source_id) REFERENCES public.sources(id); + + +-- +-- PostgreSQL database dump complete +-- + + +-- +-- Dbmate schema migrations +-- + +INSERT INTO public.schema_migrations (version) VALUES + ('20250205190533'), + ('20250206220324'), + ('20250207152518'), + ('20250207174953');