diff --git a/packages/db/migrations/0171.do.migrate_webhooks_and_exporter.sql b/packages/db/migrations/0171.do.migrate_webhooks_and_exporter.sql new file mode 100755 index 000000000..6c0b691dc --- /dev/null +++ b/packages/db/migrations/0171.do.migrate_webhooks_and_exporter.sql @@ -0,0 +1,18 @@ +-- Type: DO +-- Name: migrate_webhooks_and_exporter +-- Description: Migrate data from webhooks and exporters to rules + +BEGIN; + +-- Migrate webhooks to rules +INSERT INTO omnivore.rules (user_id, name, filter, actions, enabled, created_at, updated_at, event_types) +SELECT user_id, 'webhook', 'in:all', jsonb_build_array(jsonb_build_object('type', 'WEBHOOK', 'params', jsonb_build_array(url))), enabled, created_at, updated_at, event_types +FROM omnivore.webhooks; + +-- Migrate exporters to rules +INSERT INTO omnivore.rules (user_id, name, filter, actions, enabled, created_at, updated_at, event_types) +SELECT user_id, 'export', 'in:all', jsonb_build_array(jsonb_build_object('type', 'EXPORT', 'params', jsonb_build_array(name))), enabled, created_at, updated_at, '{PAGE_CREATED,PAGE_UPDATED,HIGHLIGHT_CREATED,LABEL_CREATED}' +FROM omnivore.integrations +WHERE type = 'EXPORT'; + +COMMIT; diff --git a/packages/db/migrations/0171.undo.migrate_webhooks_and_exporter.sql b/packages/db/migrations/0171.undo.migrate_webhooks_and_exporter.sql new file mode 100755 index 000000000..1a5755bb4 --- /dev/null +++ b/packages/db/migrations/0171.undo.migrate_webhooks_and_exporter.sql @@ -0,0 +1,7 @@ +-- Type: UNDO +-- Name: migrate_webhooks_and_exporter +-- Description: Migrate data from webhooks and exporters to rules + +BEGIN; + +COMMIT;