From 015298efb0688efaff5e9d7b9a90472961bfa6b5 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Mon, 2 Sep 2024 17:13:26 -0400 Subject: [PATCH] remove vacuuming logic --- .../src/repositories/database.repository.ts | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/server/src/repositories/database.repository.ts b/server/src/repositories/database.repository.ts index 062863d6d076c8..9ee7f8e6fcceac 100644 --- a/server/src/repositories/database.repository.ts +++ b/server/src/repositories/database.repository.ts @@ -192,13 +192,7 @@ export class DatabaseRepository implements IDatabaseRepository { } async runMigrations(options?: { transaction?: 'all' | 'none' | 'each' }): Promise { - const migrations = await this.dataSource.runMigrations(options); - if (migrations.length === 0) { - return; - } - - this.logger.debug(`Vacuuming after running migrations`); - await this.vacuum(); + await this.dataSource.runMigrations(options); } async withLock(lock: DatabaseLock, callback: () => Promise): Promise { @@ -245,23 +239,4 @@ export class DatabaseRepository implements IDatabaseRepository { private async releaseLock(lock: DatabaseLock, queryRunner: QueryRunner): Promise { return queryRunner.query('SELECT pg_advisory_unlock($1)', [lock]); } - - private async vacuum(table?: string) { - let command = table ? `vacuum analyze ${table};` : 'vacuum analyze;'; - try { - await this.dataSource.query(command); - } catch (error: any) { - this.logger.error(`Could not run command '${command}': ${error.message}`); - this.logger.error(`If using Docker Compose, you may wish to add 'shm_size: 512m' to the database service`); - - try { - command = table ? `vacuum full ${table};` : 'vacuum full;'; - this.logger.error(`Attempting '${command}' instead`); - await this.dataSource.query(command); - } catch (error: any) { - this.logger.error(`Could not run '${command}' (${error.message}). Please ensure you have enough disk space`); - this.logger.error(`For best performance, resolve the error and run the ${command} SQL command manually`); - } - } - } }