generated from alecodes/base-template
refactor!: change migration tool to sqlx
This commit is contained in:
parent
27037a9f75
commit
49c8682164
15 changed files with 30 additions and 894 deletions
72
migrations/20250415190938_create_table_entries.up.sql
Normal file
72
migrations/20250415190938_create_table_entries.up.sql
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
-- Add up migration script here
|
||||
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');
|
||||
Loading…
Add table
Add a link
Reference in a new issue