From 0e4ac3b7f3767e45e115f002acbc5c9e7e242f7d Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Mon, 8 Jul 2024 16:08:00 +0200 Subject: [PATCH] feat: Add status column to user model --- .../migrations/20240708140250_add_status_to_users.js | 11 +++++++++++ packages/backend/src/models/user.js | 12 ++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 packages/backend/src/db/migrations/20240708140250_add_status_to_users.js diff --git a/packages/backend/src/db/migrations/20240708140250_add_status_to_users.js b/packages/backend/src/db/migrations/20240708140250_add_status_to_users.js new file mode 100644 index 00000000..c47daf2a --- /dev/null +++ b/packages/backend/src/db/migrations/20240708140250_add_status_to_users.js @@ -0,0 +1,11 @@ +export async function up(knex) { + return knex.schema.table('users', (table) => { + table.string('status').defaultTo('active'); + }); +} + +export async function down(knex) { + return knex.schema.table('users', (table) => { + table.dropColumn('status'); + }); +} diff --git a/packages/backend/src/models/user.js b/packages/backend/src/models/user.js index 72dee71a..ceb4dd71 100644 --- a/packages/backend/src/models/user.js +++ b/packages/backend/src/models/user.js @@ -33,8 +33,16 @@ class User extends Base { fullName: { type: 'string', minLength: 1 }, email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 }, password: { type: 'string' }, + status: { + type: 'string', + enum: ['active', 'pending'], + default: 'active', + }, resetPasswordToken: { type: ['string', 'null'] }, - resetPasswordTokenSentAt: { type: ['string', 'null'], format: 'date-time' }, + resetPasswordTokenSentAt: { + type: ['string', 'null'], + format: 'date-time', + }, trialExpiryDate: { type: 'string' }, roleId: { type: 'string', format: 'uuid' }, deletedAt: { type: 'string' }, @@ -381,7 +389,7 @@ class User extends Base { email, password, fullName, - roleId: adminRole.id + roleId: adminRole.id, }); await Config.markInstallationCompleted();