diff --git a/server/src/schema/migrations/1792517020180-AddUpdateIdIndexes.ts b/server/src/schema/migrations/1792517020180-AddUpdateIdIndexes.ts new file mode 100644 index 000000000..881729998 --- /dev/null +++ b/server/src/schema/migrations/1792517020180-AddUpdateIdIndexes.ts @@ -0,0 +1,13 @@ +import { Kysely, sql } from 'kysely'; + +export async function up(db: Kysely): Promise { + await sql`CREATE INDEX "stack_updateId_idx" ON "stack" ("updateId");`.execute(db); + await sql`CREATE INDEX "asset_face_updateId_idx" ON "asset_face" ("updateId");`.execute(db); + await sql`CREATE INDEX "workflow_updateId_idx" ON "workflow" ("updateId");`.execute(db); +} + +export async function down(db: Kysely): Promise { + await sql`DROP INDEX "stack_updateId_idx";`.execute(db); + await sql`DROP INDEX "workflow_updateId_idx";`.execute(db); + await sql`DROP INDEX "asset_face_updateId_idx";`.execute(db); +} diff --git a/server/src/schema/migrations/ORDER b/server/src/schema/migrations/ORDER index 29bc7eaf7..a334973b4 100644 --- a/server/src/schema/migrations/ORDER +++ b/server/src/schema/migrations/ORDER @@ -100,3 +100,4 @@ 1790693088454-AddPersonUserTableSharedBySharedWithConstraint 1792213725597-AddAssetFaceAssetState 1792511451454-AddPasskeyTable +1792517020180-AddUpdateIdIndexes diff --git a/server/src/schema/tables/asset-face.table.ts b/server/src/schema/tables/asset-face.table.ts index a318cc728..a613d0c45 100644 --- a/server/src/schema/tables/asset-face.table.ts +++ b/server/src/schema/tables/asset-face.table.ts @@ -95,7 +95,7 @@ export class AssetFaceTable { @UpdateDateColumn() updatedAt!: Generated; - @UpdateIdColumn() + @UpdateIdColumn({ index: true }) updateId!: Generated; @Column({ type: 'boolean', default: true }) diff --git a/server/src/schema/tables/stack.table.ts b/server/src/schema/tables/stack.table.ts index a38b0350d..520338ee2 100644 --- a/server/src/schema/tables/stack.table.ts +++ b/server/src/schema/tables/stack.table.ts @@ -31,7 +31,7 @@ export class StackTable { @UpdateDateColumn() updatedAt!: Generated; - @UpdateIdColumn() + @UpdateIdColumn({ index: true }) updateId!: Generated; //TODO: Add constraint to ensure primary asset exists in the assets array diff --git a/server/src/schema/tables/workflow.table.ts b/server/src/schema/tables/workflow.table.ts index f27f63ef8..a313a2bb6 100644 --- a/server/src/schema/tables/workflow.table.ts +++ b/server/src/schema/tables/workflow.table.ts @@ -36,7 +36,7 @@ export class WorkflowTable { @UpdateDateColumn() updatedAt!: Generated; - @UpdateIdColumn() + @UpdateIdColumn({ index: true }) updateId!: Generated; @Column({ type: 'boolean', default: true })