aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-11-20 03:17:41 +0100
committerTeddy Wing2018-11-20 03:17:41 +0100
commit7b5863020e3d27173c82acc69fc71b62397f5c59 (patch)
tree49752c8ba233dff5296e84fcdb0ad77bf46b3167
parent2068de68350c3dd3ac527a8eb2090d0a9f961866 (diff)
downloaddome-key-web-7b5863020e3d27173c82acc69fc71b62397f5c59.tar.bz2
create_purchasers: Use a single trigger per action
Got this error from the production MySQL server: (details: Error 1235: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table') Change our triggers so we only have one for `BEFORE INSERT`.
-rw-r--r--license-generator/migrations/20181109031633_create_purchasers.down.sql5
-rw-r--r--license-generator/migrations/20181109031633_create_purchasers.up.sql13
2 files changed, 7 insertions, 11 deletions
diff --git a/license-generator/migrations/20181109031633_create_purchasers.down.sql b/license-generator/migrations/20181109031633_create_purchasers.down.sql
index 3fa17a5..ffdb8e9 100644
--- a/license-generator/migrations/20181109031633_create_purchasers.down.sql
+++ b/license-generator/migrations/20181109031633_create_purchasers.down.sql
@@ -1,8 +1,7 @@
BEGIN;
-DROP TRIGGER purchasers_created_at_before_insert;
-DROP TRIGGER purchasers_updated_at_before_insert;
-DROP TRIGGER purchasers_updated_at_before_update;
+DROP TRIGGER purchasers_before_insert;
+DROP TRIGGER purchasers_before_update;
DROP TABLE purchasers;
COMMIT;
diff --git a/license-generator/migrations/20181109031633_create_purchasers.up.sql b/license-generator/migrations/20181109031633_create_purchasers.up.sql
index 19669bd..7c6bffd 100644
--- a/license-generator/migrations/20181109031633_create_purchasers.up.sql
+++ b/license-generator/migrations/20181109031633_create_purchasers.up.sql
@@ -9,17 +9,14 @@ CREATE TABLE purchasers (
updated_at DATETIME NOT NULL
);
-CREATE TRIGGER purchasers_created_at_before_insert
+CREATE TRIGGER purchasers_before_insert
BEFORE INSERT
ON purchasers FOR EACH ROW
- SET NEW.created_at = UTC_TIMESTAMP();
+ SET
+ NEW.updated_at = UTC_TIMESTAMP(),
+ NEW.created_at = UTC_TIMESTAMP();
-CREATE TRIGGER purchasers_updated_at_before_insert
- BEFORE INSERT
- ON purchasers FOR EACH ROW
- SET NEW.updated_at = UTC_TIMESTAMP();
-
-CREATE TRIGGER purchasers_updated_at_before_update
+CREATE TRIGGER purchasers_before_update
BEFORE UPDATE
ON purchasers FOR EACH ROW
SET NEW.updated_at = UTC_TIMESTAMP();