Add is system flag to object metadata (#2481)
* Add isSystem flag to objectMetadata * squash migrations and add dataSource->objects FK * fix missing datasource enum type
This commit is contained in:
@ -5,8 +5,11 @@ import {
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
DataSourceOptions,
|
||||
OneToMany,
|
||||
} from 'typeorm';
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/metadata/object-metadata/object-metadata.entity';
|
||||
|
||||
type DataSourceType = DataSourceOptions['type'];
|
||||
|
||||
@Entity('dataSource')
|
||||
@ -29,6 +32,11 @@ export class DataSourceEntity {
|
||||
@Column({ default: false })
|
||||
isRemote: boolean;
|
||||
|
||||
@OneToMany(() => ObjectMetadataEntity, (object) => object.dataSource, {
|
||||
cascade: true,
|
||||
})
|
||||
objects: ObjectMetadataEntity[];
|
||||
|
||||
@Column({ nullable: false })
|
||||
workspaceId: string;
|
||||
|
||||
|
||||
@ -53,6 +53,9 @@ export class ObjectMetadataDTO {
|
||||
@Field()
|
||||
isActive: boolean;
|
||||
|
||||
@Field()
|
||||
isSystem: boolean;
|
||||
|
||||
@HideField()
|
||||
workspaceId: string;
|
||||
|
||||
|
||||
@ -6,12 +6,14 @@ import {
|
||||
OneToMany,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
} from 'typeorm';
|
||||
|
||||
import { ObjectMetadataInterface } from 'src/tenant/schema-builder/interfaces/object-metadata.interface';
|
||||
|
||||
import { FieldMetadataEntity } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
import { RelationMetadataEntity } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
import { DataSourceEntity } from 'src/metadata/data-source/data-source.entity';
|
||||
|
||||
@Entity('objectMetadata')
|
||||
@Unique('IndexOnNameSingularAndWorkspaceIdUnique', [
|
||||
@ -53,6 +55,9 @@ export class ObjectMetadataEntity implements ObjectMetadataInterface {
|
||||
@Column({ default: false })
|
||||
isActive: boolean;
|
||||
|
||||
@Column({ default: false })
|
||||
isSystem: boolean;
|
||||
|
||||
@Column({ nullable: false })
|
||||
workspaceId: string;
|
||||
|
||||
@ -73,6 +78,11 @@ export class ObjectMetadataEntity implements ObjectMetadataInterface {
|
||||
)
|
||||
toRelations: RelationMetadataEntity[];
|
||||
|
||||
@ManyToOne(() => DataSourceEntity, (dataSource) => dataSource.objects, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
dataSource: DataSourceEntity;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
@ -56,6 +56,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
targetTableName: `_${record.nameSingular}`,
|
||||
isActive: true,
|
||||
isCustom: true,
|
||||
isSystem: false,
|
||||
});
|
||||
|
||||
await this.tenantMigrationService.createCustomMigration(
|
||||
|
||||
Reference in New Issue
Block a user