Use composite index for tags

This commit is contained in:
Alex Gleason 2024-03-02 19:21:48 -06:00
parent 9c4301e791
commit 19adb3ab44
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import { Kysely } from '@/deps.ts';
export async function up(db: Kysely<any>): Promise<void> {
await db.schema.dropIndex('idx_tags_tag').on('tags').execute();
await db.schema.dropIndex('idx_tags_value').on('tags').execute();
await db.schema
.createIndex('idx_tags_tag_value')
.on('tags')
.columns(['tag', 'value'])
.execute();
}
export async function down(db: Kysely<any>): Promise<void> {
await db.schema
.dropIndex('idx_tags_tag_value')
.on('tags')
.execute();
await db.schema
.createIndex('idx_tags_tag')
.on('tags')
.column('tag')
.execute();
await db.schema
.createIndex('idx_tags_value')
.on('tags')
.column('value')
.execute();
}