Files
twenty_crm/server/src/metadata/tenant-migration/tenant-migration.entity.ts
Jérémy M e9827486c0 feat: add default value capability (#2544)
* feat: add default value capability

* feat: update seeds with default value
2023-11-16 18:25:11 +01:00

60 lines
1.3 KiB
TypeScript

import {
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
} from 'typeorm';
export enum TenantMigrationColumnActionType {
CREATE = 'CREATE',
RELATION = 'RELATION',
}
export type TenantMigrationColumnCreate = {
action: TenantMigrationColumnActionType.CREATE;
columnName: string;
columnType: string;
defaultValue?: any;
};
export type TenantMigrationColumnRelation = {
action: TenantMigrationColumnActionType.RELATION;
columnName: string;
referencedTableName: string;
referencedTableColumnName: string;
isUnique?: boolean;
};
export type TenantMigrationColumnAction = {
action: TenantMigrationColumnActionType;
} & (TenantMigrationColumnCreate | TenantMigrationColumnRelation);
export type TenantMigrationTableAction = {
name: string;
action: 'create' | 'alter';
columns?: TenantMigrationColumnAction[];
};
@Entity('tenantMigration')
export class TenantMigrationEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: true, type: 'jsonb' })
migrations: TenantMigrationTableAction[];
@Column({ nullable: true })
name: string;
@Column({ default: false })
isCustom: boolean;
@Column({ nullable: true })
appliedAt?: Date;
@Column()
workspaceId: string;
@CreateDateColumn()
createdAt: Date;
}