2016-02-21 01:55:44 +00:00
|
|
|
|
|
|
|
-- +goose Up
|
|
|
|
-- SQL in section 'Up' is executed when this migration is applied
|
|
|
|
ALTER TABLE campaigns ADD COLUMN smtp_id bigint;
|
2016-02-21 05:16:38 +00:00
|
|
|
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
|
2016-02-21 01:55:44 +00:00
|
|
|
ALTER TABLE smtp RENAME TO smtp_old;
|
2016-02-21 05:16:38 +00:00
|
|
|
CREATE TABLE smtp(
|
|
|
|
id integer primary key autoincrement,
|
|
|
|
user_id bigint,
|
|
|
|
interface_type varchar(255),
|
2016-02-21 19:20:56 +00:00
|
|
|
name varchar(255),
|
2016-02-21 05:16:38 +00:00
|
|
|
host varchar(255),
|
|
|
|
username varchar(255),
|
|
|
|
password varchar(255),
|
|
|
|
from_address varchar(255),
|
|
|
|
modified_date datetime default CURRENT_TIMESTAMP,
|
|
|
|
ignore_cert_errors BOOLEAN
|
|
|
|
);
|
2016-02-21 19:20:56 +00:00
|
|
|
INSERT INTO smtp (id,interface_type,name,host,username,from_address,ignore_cert_errors)
|
|
|
|
SELECT smtp_id,'SMTP',smtp_id,host,username,from_address,ignore_cert_errors
|
2016-02-21 05:16:38 +00:00
|
|
|
FROM smtp_old
|
|
|
|
;
|
|
|
|
UPDATE smtp
|
|
|
|
SET user_id = (SELECT campaigns.user_id FROM campaigns)
|
|
|
|
WHERE smtp.id = (
|
|
|
|
SELECT smtp.id
|
|
|
|
FROM smtp,campaigns
|
|
|
|
WHERE smtp.id=campaigns.smtp_id
|
|
|
|
)
|
|
|
|
;
|
2016-02-21 01:55:44 +00:00
|
|
|
DROP TABLE smtp_old;
|
|
|
|
-- +goose Down
|
|
|
|
-- SQL section 'Down' is executed when this migration is rolled back
|
|
|
|
|