From b489d407c9dff13bcbe2904afb9aafe873bb4b2d Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 7 Nov 2021 23:51:34 +0200 Subject: [PATCH] Remove old db migration that was merged into initial schema --- .../2019-05-16-message-delete-cascade.go | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 database/upgrades/2019-05-16-message-delete-cascade.go diff --git a/database/upgrades/2019-05-16-message-delete-cascade.go b/database/upgrades/2019-05-16-message-delete-cascade.go deleted file mode 100644 index 97ee5c9..0000000 --- a/database/upgrades/2019-05-16-message-delete-cascade.go +++ /dev/null @@ -1,31 +0,0 @@ -package upgrades - -import ( - "database/sql" -) - -func init() { - upgrades[1] = upgrade{"Add ON DELETE CASCADE to message table", func(tx *sql.Tx, ctx context) error { - if ctx.dialect == SQLite { - // SQLite doesn't support constraint updates, but it isn't that careful with constraints anyway. - return nil - } - res, _ := ctx.db.Query(`SELECT EXISTS(SELECT constraint_name FROM information_schema.table_constraints - WHERE table_name='message' AND constraint_name='message_chat_jid_fkey')`) - var exists bool - _ = res.Scan(&exists) - if exists { - _, err := tx.Exec("ALTER TABLE message DROP CONSTRAINT IF EXISTS message_chat_jid_fkey") - if err != nil { - return err - } - _, err = tx.Exec(`ALTER TABLE message ADD CONSTRAINT message_chat_jid_fkey - FOREIGN KEY (chat_jid, chat_receiver) REFERENCES portal(jid, receiver) - ON DELETE CASCADE`) - if err != nil { - return err - } - } - return nil - }} -}