Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): tenants table v1 #3133

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/auth/migrations/20241125233415_create_tenants_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema.createTable('tenants', function (table) {
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())
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these generated in this table, or passed over from backend?
Should we also include deletedAt?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that yes, this createdAt and updatedAt needs to be generated in this table since it is different entity. Bot somehow, still connected with the one in backend. with createdAt we get info when was the entity created in that database, not when it was created in the backed database. What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating the timestamps in this table should be fine, that's consistent with what we have everywhere else.
But we should include deletedAt column, which should just be passed in from the deleteTenant GraphQL API call.

table.timestamp('deletedAt')
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
knex.schema.dropTableIfExists('tenants')
}
12 changes: 12 additions & 0 deletions packages/auth/src/tenant/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BaseModel } from '../shared/baseModel'

export class Tenant extends BaseModel {
golobitch marked this conversation as resolved.
Show resolved Hide resolved
public static get tableName(): string {
return 'tenants'
}

public idpConsentUrl!: string
public idpSecret!: string

public deletedAt?: Date
}
Loading