Introduce remote table entity (#4994)
We will require remote table entity to map distant table name and local foreign table name. Introducing the entity: - new source of truth to know if a table is sync or not - created synchronously at the same time as metadata and foreign table Adding a few more changes: - exception rather than errors so the user can see these - `pluralize` library that will allow to stop adding `Remote` suffix on names --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -1,14 +1,16 @@
|
||||
import { ObjectType } from '@nestjs/graphql';
|
||||
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Generated,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { RemoteTableEntity } from 'src/engine/metadata-modules/remote-server/remote-table/remote-table.entity';
|
||||
|
||||
export enum RemoteServerType {
|
||||
POSTGRES_FDW = 'postgres_fdw',
|
||||
}
|
||||
@ -30,7 +32,6 @@ export type UserMappingOptions = {
|
||||
};
|
||||
|
||||
@Entity('remoteServer')
|
||||
@ObjectType('RemoteServer')
|
||||
export class RemoteServerEntity<T extends RemoteServerType> {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@ -51,6 +52,11 @@ export class RemoteServerEntity<T extends RemoteServerType> {
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@OneToMany(() => RemoteTableEntity, (table) => table.server, {
|
||||
cascade: true,
|
||||
})
|
||||
tables: Relation<RemoteTableEntity[]>;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user