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

chore(gatekeeper): add workspace_seats table and types #4062

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions packages/server/modules/gatekeeper/domain/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -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)
}
Empty file.