Add field isLabelSyncedWithName (#8829)
## Context
The recent addition of object renaming introduced issues with enum
names. Enum names should follow the pattern
`${schemaName}.${tableName}_${columnName}_enum`. To address this, and to
allow users to customize the API name (which is included in the enum
name, columnName), this PR implements behavior similar to object
renaming by introducing a `isLabelSyncedWithName` boolean.
<img width="624" alt="Screenshot 2024-12-02 at 11 58 49"
src="https://github.com/user-attachments/assets/690fb71c-83f0-4922-80c0-946c92dacc30">
<img width="596" alt="Screenshot 2024-12-02 at 11 58 39"
src="https://github.com/user-attachments/assets/af9a0037-7cf5-40c3-9ed5-d51b340c8087">
This commit is contained in:
@ -145,6 +145,11 @@ export class FieldMetadataDTO<
|
||||
|
||||
objectMetadataId: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@Field()
|
||||
isLabelSyncedWithName?: boolean;
|
||||
|
||||
@IsDateString()
|
||||
@Field()
|
||||
createdAt: Date;
|
||||
|
||||
@ -114,6 +114,9 @@ export class FieldMetadataEntity<
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ default: false })
|
||||
isLabelSyncedWithName: boolean;
|
||||
|
||||
@OneToOne(
|
||||
() => RelationMetadataEntity,
|
||||
(relation: RelationMetadataEntity) => relation.fromFieldMetadata,
|
||||
|
||||
@ -78,7 +78,7 @@ export class ObjectMetadataEntity implements ObjectMetadataInterface {
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
imageIdentifierFieldMetadataId?: string | null;
|
||||
|
||||
@Column({ default: true })
|
||||
@Column({ default: false })
|
||||
isLabelSyncedWithName: boolean;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
|
||||
@ -23,6 +23,13 @@ export class WorkspaceMigrationEnumService {
|
||||
tableName: string,
|
||||
migrationColumn: WorkspaceMigrationColumnAlter,
|
||||
) {
|
||||
const oldEnumTypeName = await this.getEnumTypeName(
|
||||
queryRunner,
|
||||
schemaName,
|
||||
tableName,
|
||||
migrationColumn.currentColumnDefinition.columnName,
|
||||
);
|
||||
|
||||
// Rename column name
|
||||
if (
|
||||
migrationColumn.currentColumnDefinition.columnName !==
|
||||
@ -37,13 +44,6 @@ export class WorkspaceMigrationEnumService {
|
||||
);
|
||||
}
|
||||
|
||||
const oldEnumTypeName = await this.getEnumTypeName(
|
||||
queryRunner,
|
||||
schemaName,
|
||||
tableName,
|
||||
migrationColumn.currentColumnDefinition.columnName,
|
||||
);
|
||||
|
||||
const columnDefinition = migrationColumn.alteredColumnDefinition;
|
||||
const tempEnumTypeName = `${oldEnumTypeName}_temp`;
|
||||
const newEnumTypeName = `${tableName}_${columnDefinition.columnName}_enum`;
|
||||
@ -236,7 +236,7 @@ export class WorkspaceMigrationEnumService {
|
||||
[schemaName, tableName, columnName],
|
||||
);
|
||||
|
||||
const enumTypeName = result[0].udt_name;
|
||||
const enumTypeName = result[0]?.udt_name;
|
||||
|
||||
if (!enumTypeName) {
|
||||
throw new WorkspaceMigrationException(
|
||||
|
||||
Reference in New Issue
Block a user