Sync-metadata swallow FK_e078063f0cbce9767a0f8ca431d (#11991)
# Introduction Encountering a blocking issue due to legacy upgrade history in staging due to relation refactor For the moment ( release 0.53 ) swallowing @charlesBochet ## How to test ```ts checkout v0.52.11 yarn database:reset checkout 0.53 yarn build server migrate upgrade ```
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
|
|
||||||
import { isDefined } from 'class-validator';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
import {
|
import {
|
||||||
QueryRunner,
|
QueryRunner,
|
||||||
Table,
|
Table,
|
||||||
@ -658,16 +658,32 @@ export class WorkspaceMigrationRunnerService {
|
|||||||
tableName: string,
|
tableName: string,
|
||||||
migrationColumn: WorkspaceMigrationColumnCreateRelation,
|
migrationColumn: WorkspaceMigrationColumnCreateRelation,
|
||||||
) {
|
) {
|
||||||
await queryRunner.createForeignKey(
|
try {
|
||||||
`${schemaName}.${tableName}`,
|
await queryRunner.createForeignKey(
|
||||||
new TableForeignKey({
|
`${schemaName}.${tableName}`,
|
||||||
columnNames: [migrationColumn.columnName],
|
new TableForeignKey({
|
||||||
referencedColumnNames: [migrationColumn.referencedTableColumnName],
|
columnNames: [migrationColumn.columnName],
|
||||||
referencedTableName: migrationColumn.referencedTableName,
|
referencedColumnNames: [migrationColumn.referencedTableColumnName],
|
||||||
referencedSchema: schemaName,
|
referencedTableName: migrationColumn.referencedTableName,
|
||||||
onDelete: convertOnDeleteActionToOnDelete(migrationColumn.onDelete),
|
referencedSchema: schemaName,
|
||||||
}),
|
onDelete: convertOnDeleteActionToOnDelete(migrationColumn.onDelete),
|
||||||
);
|
}),
|
||||||
|
);
|
||||||
|
// TODO remove me after 0.53 release @prastoin @charlesBochet Swallowing blocking false positive constraint
|
||||||
|
} catch (error) {
|
||||||
|
if (
|
||||||
|
[error.driverError.message, error.message]
|
||||||
|
.filter(isDefined)
|
||||||
|
.some((el: string) => el.includes('FK_e078063f0cbce9767a0f8ca431d'))
|
||||||
|
) {
|
||||||
|
this.logger.warn(
|
||||||
|
'Encountered a FK_e078063f0cbce9767a0f8ca431d exception, swallowing',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// End remove me
|
||||||
|
|
||||||
// Create unique constraint if for one to one relation
|
// Create unique constraint if for one to one relation
|
||||||
if (migrationColumn.isUnique) {
|
if (migrationColumn.isUnique) {
|
||||||
|
|||||||
Reference in New Issue
Block a user