mirror of
https://github.com/gophish/gophish
synced 2024-11-14 16:27:23 +00:00
Remove attempt to migrate from existing SMTP since it is unsafe in multi user environments and confusing + breaks relationships when entries are de-duped.
This commit is contained in:
parent
7d52c8a7ab
commit
5afaea8d6d
1 changed files with 1 additions and 31 deletions
|
@ -3,24 +3,8 @@
|
|||
-- SQL in section 'Up' is executed when this migration is applied
|
||||
-- Move the relationship between campaigns and smtp to campaigns
|
||||
ALTER TABLE campaigns ADD COLUMN "smtp_id" bigint;
|
||||
UPDATE campaigns
|
||||
SET smtp_id = (
|
||||
SELECT smtp.smtp_id
|
||||
FROM smtp,campaigns
|
||||
WHERE campaigns.id=smtp.campaign_id
|
||||
)
|
||||
;
|
||||
-- Add the appropriate user_id to each smtp record
|
||||
ALTER TABLE smtp ADD COLUMN "user_id" bigint;
|
||||
UPDATE smtp
|
||||
SET user_id = (
|
||||
SELECT campaigns.user_id
|
||||
FROM smtp,campaigns
|
||||
WHERE smtp.smtp_id=campaigns.smtp_id
|
||||
)
|
||||
;
|
||||
-- Create a new table to store smtp records
|
||||
ALTER TABLE smtp RENAME TO smtp_old;
|
||||
DROP TABLE smtp;
|
||||
CREATE TABLE smtp(
|
||||
id integer primary key autoincrement,
|
||||
user_id bigint,
|
||||
|
@ -33,20 +17,6 @@ CREATE TABLE smtp(
|
|||
modified_date datetime default CURRENT_TIMESTAMP,
|
||||
ignore_cert_errors BOOLEAN
|
||||
);
|
||||
-- Import existing smtp records into new format and drop the old table
|
||||
INSERT INTO smtp (id,user_id,interface_type,name,host,username,from_address,ignore_cert_errors)
|
||||
SELECT smtp_id,user_id,'SMTP',
|
||||
'Imported campaign via ' || COALESCE(host,'') || ' from ' || COALESCE(from_address,''),
|
||||
host,username,from_address,ignore_cert_errors
|
||||
FROM smtp_old
|
||||
-- Prevent insertion of duplicate records
|
||||
WHERE smtp_id IN (
|
||||
SELECT smtp_id
|
||||
FROM smtp_old
|
||||
GROUP BY user_id,host,from_address
|
||||
)
|
||||
;
|
||||
DROP TABLE smtp_old;
|
||||
-- +goose Down
|
||||
-- SQL section 'Down' is executed when this migration is rolled back
|
||||
|
||||
|
|
Loading…
Reference in a new issue