Skip to content

Commit

Permalink
Add order by indexes (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoncool authored May 16, 2024
1 parent 6c3277b commit de96614
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/db/migrations/20240516093218_revisions_add_updated_at_index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
return knex.raw(`
CREATE INDEX revisions_updated_at_idx ON revisions USING BTREE (updated_at);
`);
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(`
DROP INDEX revisions_updated_at_idx;
`);
}
13 changes: 13 additions & 0 deletions src/db/migrations/20240516093323_entries_add_created_at_index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
return knex.raw(`
CREATE INDEX entries_created_at_idx ON entries USING BTREE (created_at);
`);
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(`
DROP INDEX entries_created_at_idx;
`);
}
15 changes: 15 additions & 0 deletions src/db/migrations/20240516093411_workbooks_add_order_indexes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
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<void> {
return knex.raw(`
DROP INDEX workbooks_updated_at_idx;
DROP INDEX workbooks_created_at_idx;
`);
}
15 changes: 15 additions & 0 deletions src/db/migrations/20240516093447_collections_add_order_indexes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
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<void> {
return knex.raw(`
DROP INDEX collections_updated_at_idx;
DROP INDEX collections_created_at_idx;
`);
}

0 comments on commit de96614

Please sign in to comment.