mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 07:24:04 +08:00
3164b6981c
* feat: api keys (EE) * improvements * fix table * fix route * remove token suffix * api settings * Fix * fix * fix * fix
31 lines
1012 B
TypeScript
31 lines
1012 B
TypeScript
import { Kysely, sql } from 'kysely';
|
|
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await db.schema
|
|
.createTable('api_keys')
|
|
.addColumn('id', 'uuid', (col) =>
|
|
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
|
)
|
|
.addColumn('name', 'text', (col) => col)
|
|
.addColumn('creator_id', 'uuid', (col) =>
|
|
col.notNull().references('users.id').onDelete('cascade'),
|
|
)
|
|
.addColumn('workspace_id', 'uuid', (col) =>
|
|
col.notNull().references('workspaces.id').onDelete('cascade'),
|
|
)
|
|
.addColumn('expires_at', 'timestamptz')
|
|
.addColumn('last_used_at', 'timestamptz')
|
|
.addColumn('created_at', 'timestamptz', (col) =>
|
|
col.notNull().defaultTo(sql`now()`),
|
|
)
|
|
.addColumn('updated_at', 'timestamptz', (col) =>
|
|
col.notNull().defaultTo(sql`now()`),
|
|
)
|
|
.addColumn('deleted_at', 'timestamptz', (col) => col)
|
|
.execute();
|
|
}
|
|
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await db.schema.dropTable('api_keys').execute();
|
|
}
|