diff --git a/src/db/migrations/20240906131505_add_root_entries_index.ts b/src/db/migrations/20240906131505_add_root_entries_index.ts new file mode 100644 index 00000000..2448ffee --- /dev/null +++ b/src/db/migrations/20240906131505_add_root_entries_index.ts @@ -0,0 +1,20 @@ +import {Knex} from 'knex'; + +export async function up(knex: Knex): Promise { + return knex.raw(` + CREATE INDEX CONCURRENTLY entries_root_tenant_id_idx + ON entries(tenant_id) + WHERE + key NOT LIKE '_%/_%'; + `); +} + +export async function down(knex: Knex): Promise { + return knex.raw(` + DROP INDEX entries_root_tenant_id_idx; + `); +} + +export const config = { + transaction: false, +};