We have come across this issue, where by auto increment is removed from a column. We created a table, with one column which had the autoIncrement parameter set to true. However if you perform a renameColumn on the table it removes the auto increment from the column.
We are using:
Liquibase 2.0.1 as Maven Plugin
Eclipse Galileo
MySQL 5.1.58
Operating system Windows 7 Professional (SP1)
This is the script we used to create a new table, with a deliberate mistake in the column name:
After running this script we checked the table and as you can see in the attached document the screen shot shows the increment is set. Now when you add and run the following rename script:
autoIncrement has been removed (see attached document). The rename function does not have an autoIncrement parameter. So is this caused by Liquibase or is it that MySQL requires autoIncrement to be set.
We have a work round for now, which has got us moving again, please investigate this issue.
Environment
None
Attachments
1
Activity
Show:
Nathan Voxland July 29, 2012 at 5:28 AM
The trouble is that it is mysql that is dropping that information, not liquibase. Liquibase cannot necessarily know the state of the database when it gets to the renameColumn change in order to auto-populate the alter table information. I'll have to add support for autoIncrement (and also nullable) as additional attributes, but it will be up to you to make sure they are correctly set.
We have come across this issue, where by auto increment is removed from a column. We created a table, with one column which had the autoIncrement parameter set to true. However if you perform a renameColumn on the table it removes the auto increment from the column.
We are using:
Liquibase 2.0.1 as Maven Plugin
Eclipse Galileo
MySQL 5.1.58
Operating system Windows 7 Professional (SP1)
This is the script we used to create a new table, with a deliberate mistake in the column name:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<changeSet id="1" author="me">
<createTable tableName="City">
<column name="CITY" type="int" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="CITY_NAME" type="varchar(45)">
<constraints nullable="false" />
</column>
</createTable>
</changeSet>
<changeSet id="2" author="me">
<createTable tableName="County">
<column name="COUNTY_ID" type="int" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="COUNTY_Name" type="varchar(45)">
<constraints nullable="false" />
</column>
</createTable>
</changeSet>
</databaseChangeLog>
After running this script we checked the table and as you can see in the attached document the screen shot shows the increment is set. Now when you add and run the following rename script:
<changeSet id="3" author="me">
<renameColumn tableName="City" oldColumnName="CITY" newColumnName="CITY_ID" columnDataType="int"/>
</changeSet>
autoIncrement has been removed (see attached document). The rename function does not have an autoIncrement parameter. So is this caused by Liquibase or is it that MySQL requires autoIncrement to be set.
We have a work round for now, which has got us moving again, please investigate this issue.