|
1 | 1 | import { Injectable, Logger } from '@nestjs/common';
|
2 | 2 |
|
3 |
| -import { isDefined } from 'class-validator'; |
| 3 | +import { isDefined } from 'twenty-shared/utils'; |
4 | 4 | import {
|
5 | 5 | QueryRunner,
|
6 | 6 | Table,
|
@@ -658,16 +658,32 @@ export class WorkspaceMigrationRunnerService {
|
658 | 658 | tableName: string,
|
659 | 659 | migrationColumn: WorkspaceMigrationColumnCreateRelation,
|
660 | 660 | ) {
|
661 |
| - await queryRunner.createForeignKey( |
662 |
| - `${schemaName}.${tableName}`, |
663 |
| - new TableForeignKey({ |
664 |
| - columnNames: [migrationColumn.columnName], |
665 |
| - referencedColumnNames: [migrationColumn.referencedTableColumnName], |
666 |
| - referencedTableName: migrationColumn.referencedTableName, |
667 |
| - referencedSchema: schemaName, |
668 |
| - onDelete: convertOnDeleteActionToOnDelete(migrationColumn.onDelete), |
669 |
| - }), |
670 |
| - ); |
| 661 | + try { |
| 662 | + await queryRunner.createForeignKey( |
| 663 | + `${schemaName}.${tableName}`, |
| 664 | + new TableForeignKey({ |
| 665 | + columnNames: [migrationColumn.columnName], |
| 666 | + referencedColumnNames: [migrationColumn.referencedTableColumnName], |
| 667 | + referencedTableName: migrationColumn.referencedTableName, |
| 668 | + referencedSchema: schemaName, |
| 669 | + onDelete: convertOnDeleteActionToOnDelete(migrationColumn.onDelete), |
| 670 | + }), |
| 671 | + ); |
| 672 | + // TODO remove me after 0.53 release @prastoin @charlesBochet Swallowing blocking false positive constraint |
| 673 | + } catch (error) { |
| 674 | + if ( |
| 675 | + [error.driverError.message, error.message] |
| 676 | + .filter(isDefined) |
| 677 | + .some((el: string) => el.includes('FK_e078063f0cbce9767a0f8ca431d')) |
| 678 | + ) { |
| 679 | + this.logger.warn( |
| 680 | + 'Encountered a FK_e078063f0cbce9767a0f8ca431d exception, swallowing', |
| 681 | + ); |
| 682 | + } else { |
| 683 | + throw error; |
| 684 | + } |
| 685 | + } |
| 686 | + /// End remove me |
671 | 687 |
|
672 | 688 | // Create unique constraint if for one to one relation
|
673 | 689 | if (migrationColumn.isUnique) {
|
|
0 commit comments