Postgres migrations for the Elastic backend migration

These are cherry picked from the elastic branch so we can run them
and migrate data before moving to elastic as the primary page
backend.
This commit is contained in:
Jackson Harper
2022-03-15 14:00:12 -07:00
parent 4a5d919dcb
commit 56c45fd1f6
7 changed files with 100 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>production</string>
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:omnivore.app</string>
<string>applinks:dev.omnivore.app</string>
<string>applinks:demo.omnivore.app</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.app.omnivoreapp</string>
</array>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)app.omnivore.shared</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,15 @@
-- Type: DO
-- Name: add_elastic_page_id
-- Description: Add elastic_page_id to link/page related tables
BEGIN;
ALTER TABLE omnivore.article_saving_request ADD COLUMN elastic_page_id varchar(36);
ALTER TABLE omnivore.reaction ADD COLUMN elastic_page_id varchar(36);
ALTER TABLE omnivore.highlight ADD COLUMN elastic_page_id varchar(36);
ALTER TABLE omnivore.reminders ADD COLUMN elastic_page_id varchar(36);
ALTER TABLE omnivore.abuse_report ADD COLUMN elastic_page_id varchar(36);
ALTER TABLE omnivore.content_display_report ADD COLUMN elastic_page_id varchar(36);
ALTER TABLE omnivore.link_share_info ADD COLUMN elastic_page_id varchar(36);
COMMIT;

View File

@ -0,0 +1,15 @@
-- Type: UNDO
-- Name: add_elastic_page_id
-- Description: Add elastic_page_id to link/page related tables
BEGIN;
ALTER TABLE omnivore.article_saving_request DROP COLUMN elastic_page_id;
ALTER TABLE omnivore.reaction DROP COLUMN elastic_page_id;
ALTER TABLE omnivore.highlight DROP COLUMN elastic_page_id;
ALTER TABLE omnivore.reminders DROP COLUMN elastic_page_id;
ALTER TABLE omnivore.abuse_report DROP COLUMN elastic_page_id;
ALTER TABLE omnivore.content_display_report DROP COLUMN elastic_page_id;
ALTER TABLE omnivore.link_share_info DROP COLUMN elastic_page_id;
COMMIT;

View File

@ -0,0 +1,9 @@
-- Type: DO
-- Name: drop_not_null_on_article_id
-- Description: Drop NOT NULL on article_id in highlights table
BEGIN;
ALTER TABLE omnivore.highlight ALTER COLUMN article_id DROP NOT NULL;
COMMIT;

View File

@ -0,0 +1,9 @@
-- Type: UNDO
-- Name: drop_not_null_on_article_id
-- Description: Drop NOT NULL on article_id in highlights table
BEGIN;
ALTER TABLE omnivore.highlight ALTER COLUMN article_id SET NOT NULL;
COMMIT;

View File

@ -0,0 +1,14 @@
-- Type: DO
-- Name: migrate_elastic_page_id_data
-- Description: Migrate elastic_page_id field from article_id in highlight and article_saving_request tables
BEGIN;
UPDATE omnivore.article_saving_request
SET elastic_page_id = article_id
WHERE elastic_page_id is NULL AND article_id is NOT NULL;
UPDATE omnivore.highlight
SET elastic_page_id = article_id
WHERE elastic_page_id is NULL AND article_id is NOT NULL;
COMMIT;

View File

@ -0,0 +1,12 @@
-- Type: UNDO
-- Name: migrate_elastic_page_id_data
-- Description: Migrate elastic_page_id field from article_id in highlight and article_saving_request tables
BEGIN;
UPDATE omnivore.article_saving_request
SET elastic_page_id = null WHERE elastic_page_id is not NULL;
UPDATE omnivore.highlight
SET elastic_page_id = null WHERE elastic_page_id is not NULL;
COMMIT;