Integrate relations for remote objects (#4754)
Foreign table id cannot be a foreign key of a base table. But the current code use foreign keys to link object metadata with activities, events... So we will: - create a column without creating a foreign key - add a comment on the table schema so pg_graphql sees it as a foreign key This PR: - refactor a bit object metadata service so the mutation creation is separated into an util - adds the mutation creation for remote object relations - add a new type of mutation to create a comment --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -224,6 +224,14 @@ export class WorkspaceMigrationRunnerService {
|
||||
columnMigration.columnName,
|
||||
);
|
||||
break;
|
||||
case WorkspaceMigrationColumnActionType.CREATE_COMMENT:
|
||||
await this.createComment(
|
||||
queryRunner,
|
||||
schemaName,
|
||||
tableName,
|
||||
columnMigration.comment,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Migration column action not supported`);
|
||||
}
|
||||
@ -412,4 +420,15 @@ export class WorkspaceMigrationRunnerService {
|
||||
|
||||
return foreignKeys[0]?.constraint_name;
|
||||
}
|
||||
|
||||
private async createComment(
|
||||
queryRunner: QueryRunner,
|
||||
schemaName: string,
|
||||
tableName: string,
|
||||
comment: string,
|
||||
) {
|
||||
await queryRunner.query(`
|
||||
COMMENT ON TABLE "${schemaName}"."${tableName}" IS e'${comment}';
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user