From 6388e2b98843ad8ee5db855632334174efdaeedc Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 13 Jul 2021 11:20:23 -0700 Subject: user admin field and auth middleware --- db/migrations/20210713174217_add_admin_to_users.js | 11 +++++++++++ db/models/users.js | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 db/migrations/20210713174217_add_admin_to_users.js (limited to 'db') diff --git a/db/migrations/20210713174217_add_admin_to_users.js b/db/migrations/20210713174217_add_admin_to_users.js new file mode 100644 index 00000000..c8e009b1 --- /dev/null +++ b/db/migrations/20210713174217_add_admin_to_users.js @@ -0,0 +1,11 @@ +exports.up = async function(knex) { + return knex.schema.table("users", function(table) { + table.boolean("admin"); + }); +}; + +exports.down = async function(knex) { + return knex.schema.table("users", function(table) { + table.dropColumn("admin"); + }); +}; diff --git a/db/models/users.js b/db/models/users.js index e2275229..2abf1c79 100644 --- a/db/models/users.js +++ b/db/models/users.js @@ -10,6 +10,15 @@ const attributes = { comment: null, field: "id" }, + admin: { + type: DataTypes.BOOLEAN, + allowNull: true, + defaultValue: false, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "admin" + }, locked: { type: DataTypes.BOOLEAN, allowNull: true, -- cgit v1.2.3