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:
Paul Rastoin
2025-05-12 19:14:45 +02:00
committed by GitHub
parent 4d352cb4e4
commit 0fb5ea7d06

View File

@ -1,6 +1,6 @@
import { Injectable, Logger } from '@nestjs/common';
import { isDefined } from 'class-validator';
import { isDefined } from 'twenty-shared/utils';
import {
QueryRunner,
Table,
@ -658,16 +658,32 @@ export class WorkspaceMigrationRunnerService {
tableName: string,
migrationColumn: WorkspaceMigrationColumnCreateRelation,
) {
await queryRunner.createForeignKey(
`${schemaName}.${tableName}`,
new TableForeignKey({
columnNames: [migrationColumn.columnName],
referencedColumnNames: [migrationColumn.referencedTableColumnName],
referencedTableName: migrationColumn.referencedTableName,
referencedSchema: schemaName,
onDelete: convertOnDeleteActionToOnDelete(migrationColumn.onDelete),
}),
);
try {
await queryRunner.createForeignKey(
`${schemaName}.${tableName}`,
new TableForeignKey({
columnNames: [migrationColumn.columnName],
referencedColumnNames: [migrationColumn.referencedTableColumnName],
referencedTableName: migrationColumn.referencedTableName,
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
if (migrationColumn.isUnique) {