Do not upgrade if no migrate (#12187)
This commit is contained in:
@ -4,6 +4,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
|
import chalk from 'chalk';
|
||||||
import { Command } from 'nest-commander';
|
import { Command } from 'nest-commander';
|
||||||
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
|
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
|
||||||
import { In, Repository } from 'typeorm';
|
import { In, Repository } from 'typeorm';
|
||||||
@ -278,17 +279,18 @@ export class UpgradeCommand extends UpgradeCommandRunner {
|
|||||||
passedParams: string[],
|
passedParams: string[],
|
||||||
options: ActiveOrSuspendedWorkspacesMigrationCommandOptions,
|
options: ActiveOrSuspendedWorkspacesMigrationCommandOptions,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// Only run migrations if we have at least one workspace on version 0.53
|
|
||||||
const shouldRunMigrateAsPartOfUpgrade =
|
const shouldRunMigrateAsPartOfUpgrade =
|
||||||
await this.databaseMigrationService.shouldRunMigrationsIfAllWorkspaceAreAboveVersion0_53();
|
await this.databaseMigrationService.shouldRunMigrationsIfAllWorkspaceAreAboveVersion0_53();
|
||||||
|
|
||||||
if (shouldRunMigrateAsPartOfUpgrade) {
|
if (!shouldRunMigrateAsPartOfUpgrade) {
|
||||||
await this.databaseMigrationService.runMigrations();
|
this.logger.log(
|
||||||
} else {
|
chalk.red(
|
||||||
this.logger.log('Skipping database migrations.');
|
'Not able to run migrate command, aborting the whole migrate-upgrade operation',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
throw new Error('Could not run migration aborting');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue with the regular upgrade process
|
|
||||||
await super.runMigrationCommand(passedParams, options);
|
await super.runMigrationCommand(passedParams, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user