diff --git a/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql b/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql index 09d5f408..66f3bf04 100644 --- a/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql +++ b/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql @@ -19,6 +19,10 @@ CREATE TABLE user ( INSERT INTO user SELECT * FROM _user_old; +DROP TABLE IF EXISTS _user_old; + +DROP TRIGGER IF EXISTS `trigger_update_user_modification_time`; + CREATE TRIGGER IF NOT EXISTS `trigger_update_user_modification_time` AFTER UPDATE @@ -31,8 +35,6 @@ WHERE rowid = old.rowid; END; -DROP TABLE IF EXISTS _user_old; - DROP TABLE IF EXISTS _memo_old; ALTER TABLE memo RENAME TO _memo_old; @@ -51,6 +53,10 @@ CREATE TABLE memo ( INSERT INTO memo SELECT * FROM _memo_old; +DROP TABLE IF EXISTS _memo_old; + +DROP TRIGGER IF EXISTS `trigger_update_memo_modification_time`; + CREATE TRIGGER IF NOT EXISTS `trigger_update_memo_modification_time` AFTER UPDATE @@ -63,8 +69,6 @@ WHERE rowid = old.rowid; END; -DROP TABLE IF EXISTS _memo_old; - DROP TABLE IF EXISTS _memo_organizer_old; ALTER TABLE memo_organizer RENAME TO _memo_organizer_old; @@ -102,6 +106,10 @@ CREATE TABLE shortcut ( INSERT INTO shortcut SELECT * FROM _shortcut_old; +DROP TABLE IF EXISTS _shortcut_old; + +DROP TRIGGER IF EXISTS `trigger_update_shortcut_modification_time`; + CREATE TRIGGER IF NOT EXISTS `trigger_update_shortcut_modification_time` AFTER UPDATE @@ -114,8 +122,6 @@ WHERE rowid = old.rowid; END; -DROP TABLE IF EXISTS _shortcut_old; - DROP TABLE IF EXISTS _resource_old; ALTER TABLE resource RENAME TO _resource_old; @@ -135,6 +141,10 @@ CREATE TABLE resource ( INSERT INTO resource SELECT * FROM _resource_old; +DROP TABLE IF EXISTS _resource_old; + +DROP TRIGGER IF EXISTS `trigger_update_resource_modification_time`; + CREATE TRIGGER IF NOT EXISTS `trigger_update_resource_modification_time` AFTER UPDATE @@ -147,8 +157,6 @@ WHERE rowid = old.rowid; END; -DROP TABLE IF EXISTS _resource_old; - DROP TABLE IF EXISTS _user_setting_old; ALTER TABLE user_setting RENAME TO _user_setting_old;