Error While update column name with Liquibase xml

Viewed 803

I am trying to update database column name with help of Liquibase xml on linux machine MYSQL.

My xml code for update column is

 <renameColumn tableName="AAA" oldColumnName="bbb_id" newColumnName="ccc_id" columnDataType="bigint" />

but this line is throw error like ERROR [2017-11-16 15:42:28,247] liquibase: migrations.xml: migrations.xml::3.15.1::maulik.kakadiya: Change Set migrations.xml::3.15.1::maulik.kakadiya failed. Error: Error on rename of './MY_DB/#sql-4bf_322' to './MY_DB/AAA' (errno: 150) [Failed SQL: ALTER TABLE MY_DB.AAA CHANGE bbb_id ccc_id BIGINT]

After getting this error I have tried with bellow simple sql query

<sql>ALTER TABLE `AAA` CHANGE COLUMN `bbb_id` `ccc_id` BIGINT(20);
    <comment>find onther why, beacuse rename query throw error</comment>
</sql>

Also "bbb_id" is a foreign-key reference.

But this statement is throwing same error.

But if I have run Simple SQL query of this statement as per bellow query

ALTER TABLE `AAA` CHANGE COLUMN `bbb_id` `ccc_id` BIGINT(20);

Then this SQL query run successfully, but if I tried with Liquibase xml for same opration then this code is throwing error.

Any idea for this kind of problem?.

1 Answers

I don't know why it is happening, but I can suggest a troubleshooting step - instead of using the liquibase update command, try using the updateSQL command, which will generate the SQL that liquibase runs. Compare that to what you are doing manually and see if you can tell what the difference is.

Related