From 68efdebae6217e65148540b320c4513a9bff591c Mon Sep 17 00:00:00 2001 From: Nathan Lie Date: Mon, 25 Nov 2024 15:55:31 -0800 Subject: [PATCH 1/3] feat(auth): tenants table v1 --- .../20241125233415_create_tenants_table.js | 19 +++++++++++++++++++ packages/auth/src/tenant/model.ts | 10 ++++++++++ 2 files changed, 29 insertions(+) create mode 100644 packages/auth/migrations/20241125233415_create_tenants_table.js create mode 100644 packages/auth/src/tenant/model.ts diff --git a/packages/auth/migrations/20241125233415_create_tenants_table.js b/packages/auth/migrations/20241125233415_create_tenants_table.js new file mode 100644 index 0000000000..b2e2910a33 --- /dev/null +++ b/packages/auth/migrations/20241125233415_create_tenants_table.js @@ -0,0 +1,19 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = function (knex) { + return knex.schema.createTable('tenants', function (table) { + table.uuid('id').notNullable().primary() + table.string('idpConsentUrl').notNullable() + table.string('idpSecret').notNullable() + }) +} + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = function (knex) { + knex.schema.dropTableIfExists('tenants') +} diff --git a/packages/auth/src/tenant/model.ts b/packages/auth/src/tenant/model.ts new file mode 100644 index 0000000000..7da6076a03 --- /dev/null +++ b/packages/auth/src/tenant/model.ts @@ -0,0 +1,10 @@ +import { BaseModel } from '../shared/baseModel' + +export class Tenant extends BaseModel { + public static get tableName(): string { + return 'tenants' + } + + public idpConsentUrl!: string + public idpSecret!: string +} From 7560383a9f8005308a94570d199172090bdf20e6 Mon Sep 17 00:00:00 2001 From: Nathan Lie Date: Wed, 27 Nov 2024 10:32:57 -0800 Subject: [PATCH 2/3] fix: add updatedAt, createdAt --- .../auth/migrations/20241125233415_create_tenants_table.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/auth/migrations/20241125233415_create_tenants_table.js b/packages/auth/migrations/20241125233415_create_tenants_table.js index b2e2910a33..622c81e148 100644 --- a/packages/auth/migrations/20241125233415_create_tenants_table.js +++ b/packages/auth/migrations/20241125233415_create_tenants_table.js @@ -7,6 +7,9 @@ exports.up = function (knex) { table.uuid('id').notNullable().primary() table.string('idpConsentUrl').notNullable() table.string('idpSecret').notNullable() + + table.timestamp('createdAt').defaultTo(knex.fn.now()) + table.timestamp('updatedAt').defaultTo(knex.fn.now()) }) } From b9c2a7250d8e15b8e407c1d089ad80794ee1f25b Mon Sep 17 00:00:00 2001 From: Nathan Lie Date: Mon, 2 Dec 2024 08:50:10 -0800 Subject: [PATCH 3/3] feat: add deletedAt --- packages/auth/migrations/20241125233415_create_tenants_table.js | 1 + packages/auth/src/tenant/model.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/auth/migrations/20241125233415_create_tenants_table.js b/packages/auth/migrations/20241125233415_create_tenants_table.js index 622c81e148..765b6ea9f8 100644 --- a/packages/auth/migrations/20241125233415_create_tenants_table.js +++ b/packages/auth/migrations/20241125233415_create_tenants_table.js @@ -10,6 +10,7 @@ exports.up = function (knex) { table.timestamp('createdAt').defaultTo(knex.fn.now()) table.timestamp('updatedAt').defaultTo(knex.fn.now()) + table.timestamp('deletedAt') }) } diff --git a/packages/auth/src/tenant/model.ts b/packages/auth/src/tenant/model.ts index 7da6076a03..b135541c34 100644 --- a/packages/auth/src/tenant/model.ts +++ b/packages/auth/src/tenant/model.ts @@ -7,4 +7,6 @@ export class Tenant extends BaseModel { public idpConsentUrl!: string public idpSecret!: string + + public deletedAt?: Date }