chore(gatekeeper): add workspace_seats table and types

This commit is contained in:
Alessandro Magionami
2025-02-25 10:22:08 +01:00
parent eb050bb649
commit ca6f2da63f
3 changed files with 46 additions and 0 deletions
@@ -169,3 +169,13 @@ export type ReconcileSubscriptionData = (args: {
subscriptionData: SubscriptionDataInput
applyProrotation: boolean
}) => Promise<void>
export type WorkspaceSeatType = 'viewer' | 'editor'
export type WorkspaceSeat = {
workspaceId: string
userId: string
type: WorkspaceSeatType
createdAt: Date
updatedAt: Date
}
@@ -0,0 +1,36 @@
import { Knex } from 'knex'
const WORKSPACE_SEATS_TABLE = 'workspace_seats'
const WORKSPACES_TABLE = 'workspaces'
const USERS_TABLE = 'users'
export async function up(knex: Knex): Promise<void> {
await knex.schema.createTable(WORKSPACE_SEATS_TABLE, (table) => {
table
.text('workspaceId')
.references('id')
.inTable(WORKSPACES_TABLE)
.onDelete('cascade')
.notNullable()
table
.text('userId')
.references('id')
.inTable(USERS_TABLE)
.onDelete('cascade')
.notNullable()
table.text('type').notNullable()
table
.timestamp('createdAt', { precision: 3, useTz: true })
.defaultTo(knex.fn.now())
.notNullable()
table
.timestamp('updatedAt', { precision: 3, useTz: true })
.defaultTo(knex.fn.now())
.notNullable()
table.primary(['workspaceId', 'userId'])
})
}
export async function down(knex: Knex): Promise<void> {
await knex.schema.dropTable(WORKSPACE_SEATS_TABLE)
}