In the same table I have to migrate the values of a column to a new one; I want to create a new column, populate it with the values of the other column and remove the old column already migrated, this must only happen if the new column has not already been created.
<changeSet author="xxxx" id="00021">
<preConditions onFail="MARK_RAN">
<not>
<columnExists schemaName="schema" tableName="talbee" columnName="new_table"/>
</not>
</preConditions>
<addColumn schemaName="schema" tableName="new_table">
<column name="new_column" type="text"/>
</addColumn>
<sql>UPDATE table_name SET new_column = old_column</sql>
<dropColumn
catalogName="cat"
columnName="old_column"
schemaName="schema"
tableName="table_name">
<column name="old_column"/>
</dropColumn>
</changeSet>
Is the way I delete the old column correct?
Is it better just to rename the column?