mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 07:24:04 +08:00
e209aaa272
* Work on mentions * fix: properly parse page slug * fix editor suggestion bugs * mentions must start with whitespace * add icon to page mention render * feat: backlinks - WIP * UI - WIP * permissions check * use FTS for page suggestion * cleanup * WIP * page title fallback * feat: handle internal link paste * link styling * WIP * Switch back to LIKE operator for search suggestion * WIP * scope to workspaceId * still create link for pages not found * select necessary columns * cleanups
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { type Kysely, sql } from 'kysely';
|
|
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await db.schema
|
|
.createTable('backlinks')
|
|
.addColumn('id', 'uuid', (col) =>
|
|
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
|
)
|
|
.addColumn('source_page_id', 'uuid', (col) =>
|
|
col.references('pages.id').onDelete('cascade').notNull(),
|
|
)
|
|
.addColumn('target_page_id', 'uuid', (col) =>
|
|
col.references('pages.id').onDelete('cascade').notNull(),
|
|
)
|
|
.addColumn('workspace_id', 'uuid', (col) =>
|
|
col.references('workspaces.id').onDelete('cascade').notNull(),
|
|
)
|
|
.addColumn('created_at', 'timestamptz', (col) =>
|
|
col.notNull().defaultTo(sql`now()`),
|
|
)
|
|
.addColumn('updated_at', 'timestamptz', (col) =>
|
|
col.notNull().defaultTo(sql`now()`),
|
|
)
|
|
.addUniqueConstraint('backlinks_source_page_id_target_page_id_unique', [
|
|
'source_page_id',
|
|
'target_page_id',
|
|
])
|
|
.execute();
|
|
}
|
|
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await db.schema.dropTable('backlinks').execute();
|
|
}
|