mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-24 05:31:19 +10:00
Kysely - WIP
* create database migration files * kysely codegen * kysely migrate
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
import { Kysely } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.addForeignKeyConstraint(
|
||||
'FK_workspaces_users_creatorId',
|
||||
['creatorId'],
|
||||
'users',
|
||||
['id'],
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.addForeignKeyConstraint(
|
||||
'FK_workspaces_spaces_defaultSpaceId',
|
||||
['defaultSpaceId'],
|
||||
'spaces',
|
||||
['id'],
|
||||
)
|
||||
.onDelete('set null')
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.dropConstraint('FK_workspaces_users_creatorId')
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.dropConstraint('FK_workspaces_spaces_defaultSpaceId')
|
||||
.execute();
|
||||
}
|
||||
Reference in New Issue
Block a user