Merge pull request #2904 from omnivore-app/fix/highlight-date

add default value = now() to updatedAt field in labels, user_profile and highlight tables
This commit is contained in:
Hongbo Wu
2023-10-11 17:13:12 +08:00
committed by GitHub
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,22 @@
-- Type: DO
-- Name: add_default_value_to_updated_at
-- Description: Add default = now() to updated_at field in profile, labels and highlight table
BEGIN;
UPDATE omnivore.user_profile SET updated_at = created_at WHERE updated_at IS NULL;
ALTER TABLE omnivore.user_profile
ALTER COLUMN updated_at SET DEFAULT current_timestamp,
ALTER COLUMN updated_at SET NOT NULL;
UPDATE omnivore.labels SET updated_at = created_at WHERE updated_at IS NULL;
ALTER TABLE omnivore.labels
ALTER COLUMN updated_at SET DEFAULT current_timestamp,
ALTER COLUMN updated_at SET NOT NULL;
UPDATE omnivore.highlight SET updated_at = created_at WHERE updated_at IS NULL;
ALTER TABLE omnivore.highlight
ALTER COLUMN updated_at SET DEFAULT current_timestamp,
ALTER COLUMN updated_at SET NOT NULL;
COMMIT;

View File

@ -0,0 +1,13 @@
-- Type: UNDO
-- Name: add_default_value_to_updated_at
-- Description: Add default = now() to updated_at field in profile, labels and highlight table
BEGIN;
ALTER TABLE omnivore.user_profile ALTER COLUMN updated_at DROP NOT NULL;
ALTER TABLE omnivore.labels ALTER COLUMN updated_at DROP NOT NULL;
ALTER TABLE omnivore.highlight ALTER COLUMN updated_at DROP NOT NULL;
COMMIT;