Add indexes in node_paths and users tables

This commit is contained in:
Hakan Shehu
2025-02-20 15:38:39 +01:00
parent 81dd328d4b
commit bab5df2000
3 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import { Migration } from 'kysely';
export const createNodePathsIndexes: Migration = {
up: async (db) => {
await db.schema
.createIndex('node_paths_ancestor_id_idx')
.on('node_paths')
.column('ancestor_id')
.execute();
await db.schema
.createIndex('node_paths_descendant_id_idx')
.on('node_paths')
.column('descendant_id')
.execute();
},
down: async (db) => {
await db.schema.dropIndex('node_paths_ancestor_id_idx').execute();
await db.schema.dropIndex('node_paths_descendant_id_idx').execute();
},
};

View File

@@ -0,0 +1,14 @@
import { Migration } from 'kysely';
export const createUserAccountIdIndex: Migration = {
up: async (db) => {
await db.schema
.createIndex('users_account_id_idx')
.on('users')
.columns(['account_id'])
.execute();
},
down: async (db) => {
await db.schema.dropIndex('users_account_id_idx').execute();
},
};

View File

@@ -14,6 +14,8 @@ import { createCollaborationsTable } from './00011-create-collaborations-table';
import { createDocumentsTable } from './00012-create-documents-table';
import { createDocumentUpdatesTable } from './00013-create-document-updates-table';
import { createUploadsTable } from './00014-create-uploads-table';
import { createNodePathsIndexes } from './00015-create-node-paths-indexes';
import { createUserAccountIdIndex } from './00016-create-user-account-id-index';
export const databaseMigrations: Record<string, Migration> = {
'00001_create_accounts_table': createAccountsTable,
@@ -30,4 +32,6 @@ export const databaseMigrations: Record<string, Migration> = {
'00012_create_documents_table': createDocumentsTable,
'00013_create_document_updates_table': createDocumentUpdatesTable,
'00014_create_uploads_table': createUploadsTable,
'00015_create_node_paths_indexes': createNodePathsIndexes,
'00016_create_user_account_id_index': createUserAccountIdIndex,
};