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:
Thomas Trompette
2024-04-03 14:56:51 +02:00
committed by GitHub
parent 3b72eed2dc
commit 1c6f0eb577
9 changed files with 454 additions and 200 deletions

View File

@ -13,6 +13,7 @@ export enum WorkspaceMigrationColumnActionType {
CREATE_FOREIGN_KEY = 'CREATE_FOREIGN_KEY',
DROP_FOREIGN_KEY = 'DROP_FOREIGN_KEY',
DROP = 'DROP',
CREATE_COMMENT = 'CREATE_COMMENT',
}
export type WorkspaceMigrationEnum = string | { from: string; to: string };
@ -56,6 +57,11 @@ export type WorkspaceMigrationColumnDrop = {
columnName: string;
};
export type WorkspaceMigrationCreateComment = {
action: WorkspaceMigrationColumnActionType.CREATE_COMMENT;
comment: string;
};
export type WorkspaceMigrationColumnAction = {
action: WorkspaceMigrationColumnActionType;
} & (
@ -64,6 +70,7 @@ export type WorkspaceMigrationColumnAction = {
| WorkspaceMigrationColumnCreateRelation
| WorkspaceMigrationColumnDropRelation
| WorkspaceMigrationColumnDrop
| WorkspaceMigrationCreateComment
);
export type WorkspaceMigrationTableAction = {