diff --git a/src/db/migrations/012_tags_composite_index.ts b/src/db/migrations/012_tags_composite_index.ts new file mode 100644 index 0000000..418df28 --- /dev/null +++ b/src/db/migrations/012_tags_composite_index.ts @@ -0,0 +1,31 @@ +import { Kysely } from '@/deps.ts'; + +export async function up(db: Kysely): Promise { + 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): Promise { + 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(); +}