From da1407ea50ea519956dc0be646ee6398898d9b70 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 25 Mar 2023 03:37:17 +0400 Subject: [PATCH] Add column `inflections.index` --- 20230324233151_inflections_index.down.sql | 1 + 20230324233151_inflections_index.up.sql | 1 + 20230324233457_inflections_index_notnull_positive.down.sql | 5 +++++ 20230324233457_inflections_index_notnull_positive.up.sql | 5 +++++ 4 files changed, 12 insertions(+) create mode 100644 20230324233151_inflections_index.down.sql create mode 100644 20230324233151_inflections_index.up.sql create mode 100644 20230324233457_inflections_index_notnull_positive.down.sql create mode 100644 20230324233457_inflections_index_notnull_positive.up.sql diff --git a/20230324233151_inflections_index.down.sql b/20230324233151_inflections_index.down.sql new file mode 100644 index 0000000..19f67e1 --- /dev/null +++ b/20230324233151_inflections_index.down.sql @@ -0,0 +1 @@ +ALTER TABLE inflections DROP COLUMN index; diff --git a/20230324233151_inflections_index.up.sql b/20230324233151_inflections_index.up.sql new file mode 100644 index 0000000..52bf39d --- /dev/null +++ b/20230324233151_inflections_index.up.sql @@ -0,0 +1 @@ +ALTER TABLE inflections ADD COLUMN index BIGINT; diff --git a/20230324233457_inflections_index_notnull_positive.down.sql b/20230324233457_inflections_index_notnull_positive.down.sql new file mode 100644 index 0000000..cecdc67 --- /dev/null +++ b/20230324233457_inflections_index_notnull_positive.down.sql @@ -0,0 +1,5 @@ +BEGIN; +ALTER TABLE inflections ALTER COLUMN index DROP NOT NULL; +ALTER TABLE inflections DROP CONSTRAINT index_is_not_negative; +DROP INDEX inflections_part_id_index; +COMMIT; diff --git a/20230324233457_inflections_index_notnull_positive.up.sql b/20230324233457_inflections_index_notnull_positive.up.sql new file mode 100644 index 0000000..801ee15 --- /dev/null +++ b/20230324233457_inflections_index_notnull_positive.up.sql @@ -0,0 +1,5 @@ +BEGIN; +ALTER TABLE inflections ALTER COLUMN index SET NOT NULL; +ALTER TABLE inflections ADD CONSTRAINT index_is_not_negative CHECK (index >= 0); +CREATE UNIQUE INDEX inflections_part_id_index ON inflections (part_id, index); +COMMIT;