Changing name of mandatory Enum Attribute causes entire column reset to first Enum value

Cuba ver. 6.6.2
Postgres 9.4

I have a Customer Entity with “hair” attribute which is Enum (red:“R”, brown:“Br”) when I change the name of the Attribute to “hairColor” the following sql script is generated:

alter table SAAS_CUSTOMER add column HAIR_COLOR varchar(50) ^
update SAAS_CUSTOMER set HAIR_COLOR = ‘R’ where HAIR_COLOR is null ;
alter table SAAS_CUSTOMER alter column HAIR_COLOR set not null ;
alter table SAAS_CUSTOMER drop column HAIR cascade ;

It is clear from the script that the new column is populated with the first Enum value and the old column is just dropped.

Right. Studio cannot rename columns when you rename attributes, by the following reason: when it generates update scripts, it cannot match the new attribute with the old column. It just has the hairColor without a corresponding column in the model and the HAIR column in the database not mapped to any attribute. So it generates these drop/create statements.

However, you can change the script manually before execution.

1 Like