diff options
| -rw-r--r-- | license-generator/migrations/20181108234653_create-purchasers/down.sql | 6 | ||||
| -rw-r--r-- | license-generator/migrations/20181108234653_create-purchasers/up.sql | 21 | 
2 files changed, 27 insertions, 0 deletions
| diff --git a/license-generator/migrations/20181108234653_create-purchasers/down.sql b/license-generator/migrations/20181108234653_create-purchasers/down.sql new file mode 100644 index 0000000..d17db9c --- /dev/null +++ b/license-generator/migrations/20181108234653_create-purchasers/down.sql @@ -0,0 +1,6 @@ +BEGIN; + +DROP TRIGGER purchasers_updated_at; +DROP TABLE purchasers; + +COMMIT; diff --git a/license-generator/migrations/20181108234653_create-purchasers/up.sql b/license-generator/migrations/20181108234653_create-purchasers/up.sql new file mode 100644 index 0000000..14927c2 --- /dev/null +++ b/license-generator/migrations/20181108234653_create-purchasers/up.sql @@ -0,0 +1,21 @@ +BEGIN; + +CREATE TABLE purchasers ( +    id INT AUTO_INCREMENT PRIMARY KEY, +    name VARCHAR(255) NOT NULL, +    email VARCHAR(255) NOT NULL, +    secret VARCHAR(255), +    created_at DATETIME NOT NULL DEFAULT UTC_TIMESTAMP(), +    updated_at DATETIME NOT NULL DEFAULT UTC_TIMESTAMP() +); + +DELIMITER $$ +    CREATE TRIGGER purchasers_updated_at +    BEFORE UPDATE +    ON purchasers FOR EACH ROW +    BEGIN +        SET NEW.updated_at = UTC_TIMESTAMP(); +    END$$ +DELIMITER ; + +COMMIT; | 
