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>
46 lines
972 B
TypeScript
46 lines
972 B
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
Relation,
|
|
} from 'typeorm';
|
|
|
|
import {
|
|
RemoteServerEntity,
|
|
RemoteServerType,
|
|
} from 'src/engine/metadata-modules/remote-server/remote-server.entity';
|
|
|
|
@Entity('remoteTable')
|
|
export class RemoteTableEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ nullable: false })
|
|
distantTableName: string;
|
|
|
|
@Column({ nullable: false })
|
|
localTableName: string;
|
|
|
|
@Column({ nullable: false, type: 'uuid' })
|
|
workspaceId: string;
|
|
|
|
@Column({ nullable: false, type: 'uuid' })
|
|
remoteServerId: string;
|
|
|
|
@ManyToOne(() => RemoteServerEntity, (server) => server.tables, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'remoteServerId' })
|
|
server: Relation<RemoteServerEntity<RemoteServerType>>;
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
}
|