From 5077ba9f1f49dc63401b43afe949cc9730d82f5f Mon Sep 17 00:00:00 2001 From: William Woodson Date: Sat, 20 Feb 2016 19:55:44 -0600 Subject: [PATCH] Added DB migration to support storing SMTP settings as independent objects --- .../20160221001538_0.1.2_store-smtp-settings.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 db/migrations/20160221001538_0.1.2_store-smtp-settings.sql diff --git a/db/migrations/20160221001538_0.1.2_store-smtp-settings.sql b/db/migrations/20160221001538_0.1.2_store-smtp-settings.sql new file mode 100644 index 00000000..59181ca6 --- /dev/null +++ b/db/migrations/20160221001538_0.1.2_store-smtp-settings.sql @@ -0,0 +1,14 @@ + +-- +goose Up +-- SQL in section 'Up' is executed when this migration is applied +ALTER TABLE campaigns ADD COLUMN smtp_id bigint; +UPDATE campaigns SET smtp_id = (SELECT smtp.smtp_id FROM smtp) WHERE campaigns.id = (SELECT smtp.smtp_id FROM smtp,campaigns WHERE smtp.campaign_id=campaigns.id); -- sure hope the current smtp table works like I think it does + +ALTER TABLE smtp RENAME TO smtp_old; +CREATE TABLE smtp(id integer primary key autoincrement,host varchar(255),username varchar(255),from_address varchar(255) ,ignore_cert_errors BOOLEAN); +INSERT INTO smtp SELECT smtp_id AS id,host,username,from_address,ignore_cert_errors FROM smtp_old; +DROP TABLE smtp_old; + +-- +goose Down +-- SQL section 'Down' is executed when this migration is rolled back +