diff --git a/packages/db/migrations/0159.do.alter_subscriptions.sql b/packages/db/migrations/0159.do.alter_subscriptions.sql new file mode 100755 index 000000000..4b15c50fa --- /dev/null +++ b/packages/db/migrations/0159.do.alter_subscriptions.sql @@ -0,0 +1,19 @@ +-- Type: DO +-- Name: alter_subscriptions +-- Description: Alter omnivore.subscriptions table to add a new state and date column + +BEGIN; + +ALTER TYPE subscription_status_type + ADD VALUE IF NOT EXISTS 'REFRESH_ERROR'; + +ALTER TABLE omnivore.subscriptions + ADD COLUMN refreshed_at timestamptz; +UPDATE omnivore.subscriptions + SET refreshed_at = last_fetched_at + WHERE last_fetched_at IS NOT NULL; + +ALTER TABLE omnivore.subscriptions + RENAME COLUMN last_fetched_at TO most_recent_item_date; + +COMMIT; diff --git a/packages/db/migrations/0159.undo.alter_subscriptions.sql b/packages/db/migrations/0159.undo.alter_subscriptions.sql new file mode 100755 index 000000000..7e4e59f4a --- /dev/null +++ b/packages/db/migrations/0159.undo.alter_subscriptions.sql @@ -0,0 +1,13 @@ +-- Type: UNDO +-- Name: alter_subscriptions +-- Description: Alter omnivore.subscriptions table to add a new state and date column + +BEGIN; + +ALTER TABLE omnivore.subscriptions + RENAME COLUMN most_recent_item_date TO last_fetched_at; + +ALTER TABLE omnivore.subscriptions + DROP COLUMN refreshed_at; + +COMMIT;