chore(gatekeeper): add workspace_seats table and types
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
+36
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user