Have you seen the Merge Columns refactoring? Maybe that would help?
http://www.liquibase.org/manual/merge_columns
My apologies if you tried this.
Best,
Laird
Have you seen the Merge Columns refactoring? Maybe that would help?
http://www.liquibase.org/manual/merge_columns
My apologies if you tried this.
Best,
Laird
I haven’t found any easy solution with LiquiBase version 2.0.1 for the next - and I think quite common - scenario. (Sure the <sql> tag could be used.)
A new not null column needs to be added to an existing table SCENARIO_FILE(ID, SCENARIO_TYPE) and the new value should be the concatenated value of the existing values (CONCAT). This changeset is made for an Oracle database.
A) If the next changeset is used
<changeSet author=“ferengra” id=“1103081611-1” dbms=“oracle”>
<addColumn tableName=“SCENARIO_FILE”>
<column name=“SCENARIO_NAME” type=“VARCHAR2(500)” />
</addColumn>
<addNotNullConstraint tableName=“SCENARIO_FILE” columnName=“SCENARIO_NAME” defaultNullValue=“CONCAT(SCENARIO_TYPE, ID)” />
</changeSet>
, the result after updateSQL is:
Well, the SQL concat function is in quotes, so it’ll never be executed, but used as text.
B) With
, the result SQL is:
Again the same issue.
C) With defaultValue, defaultValueComputed at
, the generated value is NULL.
D) However, if the valueNumeric is used with an extra space at the end!
, the update SQL is OK. Of course, the valueNumeric is not intended for this kind of purpose, but its result is what is expected in adding a new column cases.
Can someone help me out why the <addNotNullConstraint> puts the values in quotes, why one of the column attributes can not be used for inserting an SQL call and why the extra space at the valueNumeric is necessary?
Thanks.
The mergeColumns updates the column properly but it drops the columns afterwards
Thanks for the idea anyway.