Add basic fields metadata (#2523)
* Add basic fields metadata * add fieldmetadata dependency * re-arrange modules * fix * fix seed * set default fields nullable * set default fields nullable * fix tenantMigration order * fix tenantMigration order
This commit is contained in:
@ -11,6 +11,7 @@ import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm';
|
||||
import { TenantMigrationService } from 'src/metadata/tenant-migration/tenant-migration.service';
|
||||
import { TenantMigrationRunnerService } from 'src/tenant-migration-runner/tenant-migration-runner.service';
|
||||
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
|
||||
import { ObjectMetadataEntity } from './object-metadata.entity';
|
||||
|
||||
@ -57,6 +58,55 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
isActive: true,
|
||||
isCustom: true,
|
||||
isSystem: false,
|
||||
fields:
|
||||
// Creating default fields.
|
||||
// No need to create a custom migration for this though as the default columns are already
|
||||
// created with default values which is not supported yet by tenant migrations.
|
||||
[
|
||||
{
|
||||
type: FieldMetadataType.UUID,
|
||||
name: 'id',
|
||||
label: 'Id',
|
||||
targetColumnMap: {
|
||||
value: 'id',
|
||||
},
|
||||
icon: undefined,
|
||||
description: 'Id',
|
||||
isNullable: true,
|
||||
isActive: true,
|
||||
isCustom: false,
|
||||
// isSystem: true,
|
||||
workspaceId: record.workspaceId,
|
||||
},
|
||||
{
|
||||
type: FieldMetadataType.DATE,
|
||||
name: 'createdAt',
|
||||
label: 'Creation date',
|
||||
targetColumnMap: {
|
||||
value: 'createdAt',
|
||||
},
|
||||
icon: 'IconCalendar',
|
||||
description: 'Creation date',
|
||||
isNullable: true,
|
||||
isActive: true,
|
||||
isCustom: false,
|
||||
workspaceId: record.workspaceId,
|
||||
},
|
||||
{
|
||||
type: FieldMetadataType.DATE,
|
||||
name: 'updatedAt',
|
||||
label: 'Update date',
|
||||
targetColumnMap: {
|
||||
value: 'updatedAt',
|
||||
},
|
||||
icon: 'IconCalendar',
|
||||
description: 'Update date',
|
||||
isNullable: true,
|
||||
isActive: true,
|
||||
isCustom: false,
|
||||
workspaceId: record.workspaceId,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await this.tenantMigrationService.createCustomMigration(
|
||||
|
||||
@ -6,11 +6,11 @@ import {
|
||||
} from '@ptc-org/nestjs-query-graphql';
|
||||
import { NestjsQueryTypeOrmModule } from '@ptc-org/nestjs-query-typeorm';
|
||||
|
||||
import { JwtAuthGuard } from 'src/guards/jwt.auth.guard';
|
||||
import { FieldMetadataModule } from 'src/metadata/field-metadata/field-metadata.module';
|
||||
import { ObjectMetadataModule } from 'src/metadata/object-metadata/object-metadata.module';
|
||||
import { TenantMigrationRunnerModule } from 'src/tenant-migration-runner/tenant-migration-runner.module';
|
||||
import { TenantMigrationModule } from 'src/metadata/tenant-migration/tenant-migration.module';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt.auth.guard';
|
||||
import { TenantMigrationRunnerModule } from 'src/tenant-migration-runner/tenant-migration-runner.module';
|
||||
|
||||
import { RelationMetadataService } from './relation-metadata.service';
|
||||
import { RelationMetadataEntity } from './relation-metadata.entity';
|
||||
|
||||
@ -62,7 +62,7 @@ export class TenantMigrationService {
|
||||
workspaceId: string,
|
||||
): Promise<TenantMigrationEntity[]> {
|
||||
return await this.tenantMigrationRepository.find({
|
||||
order: { createdAt: 'ASC' },
|
||||
order: { createdAt: 'ASC', name: 'ASC' },
|
||||
where: {
|
||||
appliedAt: IsNull(),
|
||||
workspaceId,
|
||||
|
||||
Reference in New Issue
Block a user