From a5ae2653d8ccdaf00270c0c8c8a30b88d7955114 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 1 Feb 2020 16:33:56 +0200 Subject: Do stuff --- backend/migrations/20200201152838_initial.js | 12 ++++++++++++ backend/migrations/20200201153559_tokens.js | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 backend/migrations/20200201152838_initial.js create mode 100644 backend/migrations/20200201153559_tokens.js (limited to 'backend/migrations') diff --git a/backend/migrations/20200201152838_initial.js b/backend/migrations/20200201152838_initial.js new file mode 100644 index 0000000..3131525 --- /dev/null +++ b/backend/migrations/20200201152838_initial.js @@ -0,0 +1,12 @@ +exports.up = function(knex) { + return knex.schema.createTable('users', function(table) { + table.increments(); + table.string('username').notNullable(); + table.string('password').notNullable(); + table.timestamps(true, true); + }); +}; + +exports.down = function(knex) { + return knex.schema.dropTable('users'); +}; diff --git a/backend/migrations/20200201153559_tokens.js b/backend/migrations/20200201153559_tokens.js new file mode 100644 index 0000000..70593fc --- /dev/null +++ b/backend/migrations/20200201153559_tokens.js @@ -0,0 +1,14 @@ +exports.up = function(knex) { + return knex.schema.createTable('tokens', function(table) { + table.increments(); + table.integer('user_id').unsigned().notNullable(); + table.foreign('user_id').references('users.id'); + table.enu('type', [ 'session' ]).notNullable(); + table.string('value').notNullable(); + table.timestamps(true, true); + }); +}; + +exports.down = function(knex) { + return knex.schema.dropTable('tokens'); +}; -- cgit v1.3