diff --git a/src/db/migrations/20240516093218_revisions_add_updated_at_index.ts b/src/db/migrations/20240516093218_revisions_add_updated_at_index.ts new file mode 100644 index 00000000..8e7275cb --- /dev/null +++ b/src/db/migrations/20240516093218_revisions_add_updated_at_index.ts @@ -0,0 +1,13 @@ +import type {Knex} from 'knex'; + +export async function up(knex: Knex): Promise { + return knex.raw(` + CREATE INDEX revisions_updated_at_idx ON revisions USING BTREE (updated_at); + `); +} + +export async function down(knex: Knex): Promise { + return knex.raw(` + DROP INDEX revisions_updated_at_idx; + `); +} diff --git a/src/db/migrations/20240516093323_entries_add_created_at_index.ts b/src/db/migrations/20240516093323_entries_add_created_at_index.ts new file mode 100644 index 00000000..fc5b17e2 --- /dev/null +++ b/src/db/migrations/20240516093323_entries_add_created_at_index.ts @@ -0,0 +1,13 @@ +import type {Knex} from 'knex'; + +export async function up(knex: Knex): Promise { + return knex.raw(` + CREATE INDEX entries_created_at_idx ON entries USING BTREE (created_at); + `); +} + +export async function down(knex: Knex): Promise { + return knex.raw(` + DROP INDEX entries_created_at_idx; + `); +} diff --git a/src/db/migrations/20240516093411_workbooks_add_order_indexes.ts b/src/db/migrations/20240516093411_workbooks_add_order_indexes.ts new file mode 100644 index 00000000..b7cc0869 --- /dev/null +++ b/src/db/migrations/20240516093411_workbooks_add_order_indexes.ts @@ -0,0 +1,15 @@ +import type {Knex} from 'knex'; + +export async function up(knex: Knex): Promise { + return knex.raw(` + CREATE INDEX workbooks_created_at_idx ON workbooks USING BTREE (created_at); + CREATE INDEX workbooks_updated_at_idx ON workbooks USING BTREE (updated_at); + `); +} + +export async function down(knex: Knex): Promise { + return knex.raw(` + DROP INDEX workbooks_updated_at_idx; + DROP INDEX workbooks_created_at_idx; + `); +} diff --git a/src/db/migrations/20240516093447_collections_add_order_indexes.ts b/src/db/migrations/20240516093447_collections_add_order_indexes.ts new file mode 100644 index 00000000..3e19abbc --- /dev/null +++ b/src/db/migrations/20240516093447_collections_add_order_indexes.ts @@ -0,0 +1,15 @@ +import type {Knex} from 'knex'; + +export async function up(knex: Knex): Promise { + return knex.raw(` + CREATE INDEX collections_created_at_idx ON collections USING BTREE (created_at); + CREATE INDEX collections_updated_at_idx ON collections USING BTREE (updated_at); + `); +} + +export async function down(knex: Knex): Promise { + return knex.raw(` + DROP INDEX collections_updated_at_idx; + DROP INDEX collections_created_at_idx; + `); +}