summaryrefslogtreecommitdiffstats
path: root/backend/migrations
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@eficode.com>2020-02-05 22:31:16 +0200
committerJan Tuomi <jan.tuomi@eficode.com>2020-02-05 22:31:16 +0200
commit72b5fc9357f0100f4cc560c1430f7ea2d849eb40 (patch)
tree81acb78eae4f69e7b24b2c2d3359d63ba44a82c2 /backend/migrations
parent6327535653f5ff1abc9f5bbf666268d41abb4d74 (diff)
Implement account activation
Diffstat (limited to 'backend/migrations')
-rw-r--r--backend/migrations/20200205194947_user_add_activated_email.js13
-rw-r--r--backend/migrations/20200205200212_add_activate_code_token_type.js17
2 files changed, 30 insertions, 0 deletions
diff --git a/backend/migrations/20200205194947_user_add_activated_email.js b/backend/migrations/20200205194947_user_add_activated_email.js
new file mode 100644
index 0000000..cf58c35
--- /dev/null
+++ b/backend/migrations/20200205194947_user_add_activated_email.js
@@ -0,0 +1,13 @@
+exports.up = function(knex) {
+ return knex.schema.table('users', function(table) {
+ table.string('email').notNullable().default('');
+ table.boolean('activated').notNullable().default(false);
+ });
+};
+
+exports.down = function(knex) {
+ return knex.schema.table('users', function(table) {
+ table.dropColumn('email');
+ table.dropColumn('activated');
+ });
+};
diff --git a/backend/migrations/20200205200212_add_activate_code_token_type.js b/backend/migrations/20200205200212_add_activate_code_token_type.js
new file mode 100644
index 0000000..b1c264c
--- /dev/null
+++ b/backend/migrations/20200205200212_add_activate_code_token_type.js
@@ -0,0 +1,17 @@
+exports.up = function(knex) {
+ return knex.schema.raw(`
+ ALTER TABLE "tokens"
+ DROP CONSTRAINT "tokens_type_check",
+ ADD CONSTRAINT "tokens_type_check"
+ CHECK (type IN ('session', 'activation'))
+ `);
+};
+
+exports.down = function(knex) {
+ return knex.schema.raw(`
+ ALTER TABLE "tokens"
+ DROP CONSTRAINT "tokens_type_check",
+ ADD CONSTRAINT "tokens_type_check"
+ CHECK (type IN ('session'))
+ `);
+};