From 47ed5193769caf149eea73130e77e47627cf169e Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 22 Feb 2021 21:16:28 -0900 Subject: [PATCH] Update database schema to not allow null previous_content --- .../migrations/000005_remove_null_from_lists.down.sql | 6 ++++++ .../migrations/000005_remove_null_from_lists.up.sql | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 pkg/database/migrations/000005_remove_null_from_lists.down.sql create mode 100644 pkg/database/migrations/000005_remove_null_from_lists.up.sql diff --git a/pkg/database/migrations/000005_remove_null_from_lists.down.sql b/pkg/database/migrations/000005_remove_null_from_lists.down.sql new file mode 100644 index 0000000..8aebab5 --- /dev/null +++ b/pkg/database/migrations/000005_remove_null_from_lists.down.sql @@ -0,0 +1,6 @@ +BEGIN; + ALTER TABLE messages + ALTER COLUMN previous_content DROP NOT NULL; + ALTER TABLE messages + ALTER COLUMN previous_content DROP DEFAULT; +COMMIT; diff --git a/pkg/database/migrations/000005_remove_null_from_lists.up.sql b/pkg/database/migrations/000005_remove_null_from_lists.up.sql new file mode 100644 index 0000000..a1b8444 --- /dev/null +++ b/pkg/database/migrations/000005_remove_null_from_lists.up.sql @@ -0,0 +1,7 @@ +BEGIN; + UPDATE messages SET previous_content = array[]::varchar[]; + ALTER TABLE messages + ALTER COLUMN previous_content SET NOT NULL; + ALTER TABLE messages + ALTER COLUMN prevous_content SET DEFAULT array[]::varchar[] +COMMIT;