diff --git a/migrations/mysql/2026-06-18-120000_add_sends_emails/down.sql b/migrations/mysql/2026-06-18-120000_add_sends_emails/down.sql index e69de29b..940f3d3e 100644 --- a/migrations/mysql/2026-06-18-120000_add_sends_emails/down.sql +++ b/migrations/mysql/2026-06-18-120000_add_sends_emails/down.sql @@ -0,0 +1,10 @@ +DROP TABLE sends_otp; + +ALTER TABLE sends DROP COLUMN auth_type; +ALTER TABLE sends DROP COLUMN emails; + +ALTER TABLE sends MODIFY user_uuid CHAR(36) NULL; +ALTER TABLE sends MODIFY hide_email BOOLEAN NULL; + +ALTER TABLE sends ADD COLUMN organization_uuid CHAR(36); +ALTER TABLE sends ADD FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid); diff --git a/migrations/postgresql/2026-06-18-120000_add_sends_emails/down.sql b/migrations/postgresql/2026-06-18-120000_add_sends_emails/down.sql index e69de29b..f6229112 100644 --- a/migrations/postgresql/2026-06-18-120000_add_sends_emails/down.sql +++ b/migrations/postgresql/2026-06-18-120000_add_sends_emails/down.sql @@ -0,0 +1,9 @@ +DROP TABLE sends_otp; + +ALTER TABLE sends DROP COLUMN auth_type; +ALTER TABLE sends DROP COLUMN emails; + +ALTER TABLE sends ALTER COLUMN user_uuid DROP NOT NULL; +ALTER TABLE sends ALTER COLUMN hide_email DROP NOT NULL; + +ALTER TABLE sends ADD COLUMN organization_uuid TEXT REFERENCES organizations(uuid); diff --git a/migrations/sqlite/2026-06-18-120000_add_sends_emails/down.sql b/migrations/sqlite/2026-06-18-120000_add_sends_emails/down.sql index e69de29b..eaba43d7 100644 --- a/migrations/sqlite/2026-06-18-120000_add_sends_emails/down.sql +++ b/migrations/sqlite/2026-06-18-120000_add_sends_emails/down.sql @@ -0,0 +1,41 @@ +DROP TABLE sends_otp; + +ALTER TABLE sends RENAME TO sends_old; + +CREATE TABLE sends ( + uuid TEXT NOT NULL PRIMARY KEY, + user_uuid TEXT REFERENCES users (uuid), + organization_uuid TEXT REFERENCES organizations (uuid), + + name TEXT NOT NULL, + notes TEXT, + + atype INTEGER NOT NULL, + data TEXT NOT NULL, + akey TEXT NOT NULL, + password_hash BLOB, + password_salt BLOB, + password_iter INTEGER, + + max_access_count INTEGER, + access_count INTEGER NOT NULL, + + creation_date DATETIME NOT NULL, + revision_date DATETIME NOT NULL, + expiration_date DATETIME, + deletion_date DATETIME NOT NULL, + + disabled BOOLEAN NOT NULL, + hide_email BOOLEAN +); + +INSERT INTO sends( + uuid, user_uuid, name, notes, atype, data, akey, password_hash, password_salt, password_iter, + max_access_count, access_count, creation_date, revision_date, expiration_date, deletion_date, + disabled, hide_email +) SELECT uuid, user_uuid, name, notes, atype, data, akey, password_hash, password_salt, password_iter, + max_access_count, access_count, creation_date, revision_date, expiration_date, deletion_date, + disabled, hide_email + FROM sends_old WHERE user_uuid IS NOT NULL; + +DROP TABLE sends_old;