From 72b5fc9357f0100f4cc560c1430f7ea2d849eb40 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 5 Feb 2020 22:31:16 +0200 Subject: Implement account activation --- .../20200205194947_user_add_activated_email.js | 13 +++++++++++++ .../20200205200212_add_activate_code_token_type.js | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 backend/migrations/20200205194947_user_add_activated_email.js create mode 100644 backend/migrations/20200205200212_add_activate_code_token_type.js (limited to 'backend/migrations') 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')) + `); +}; -- cgit v1.3