Do not upgrade if no migrate (#12187)

This commit is contained in:
Paul Rastoin
2025-05-21 16:01:03 +02:00
committed by GitHub
parent a5b212369b
commit 85a17a54b3

View File

@ -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);
} }
} }