CLONE - generateChangeLog creates DOUBLE(22) instead of double in MySql
Description
Environment
Ubuntu, MySQL 5.5
Activity
Nathan Voxland July 28, 2015 at 4:09 PM
Apparently mysql will return only one parameters if none are originally specified. Ignoring it unless there are two parameters.
Deepa V S July 1, 2015 at 6:51 AM
I have used MySQL5.1 and liquibase-core 3.4.0 generateChangeLog command and got like this in my changeset,
<column name="latitude" type="DOUBLE(22)"/>
<column name="longitude" type="DOUBLE(22)"/>
When I try to update a new database with this, I am getting the above mentioned error which is given below.
*_12:28:47,164 ERROR [org.apache.catalina.core.ContainerBase.jboss.web.default-host./mds] (MSC service thread 1-9) Exception sending context initialized
event to listener instance of class liquibase.integration.servlet.LiquibaseServletListener: java.lang.RuntimeException: liquibase.exception.MigrationFailedEx
ception: Migration failed for change set db/migration/changelog-initial.xml::1435731060394-8::deepavs (generated):
Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near ') NULL, longitude DOUBLE(22) NULL, createdBy VARCHAR(255) NULL, CONSTRAINT PK_CO' at line 1 [Failed SQL: CREATE TABLE mds_prod_
temp.coordinate (id BIGINT AUTO_INCREMENT NOT NULL, dateCreated datetime NOT NULL, lastModified datetime NOT NULL, revision BIGINT NULL, uuid VARCHAR(255) NO
T NULL, version BIGINT NULL, latitude DOUBLE(22) NULL, longitude DOUBLE(22) NULL, createdBy VARCHAR(255) NULL, CONSTRAINT PK_COORDINATE PRIMARY KEY (id))]
at liquibase.integration.servlet.LiquibaseServletListener.contextInitialized(LiquibaseServletListener.java:123) [liquibase-core-3.4.0.jar:]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) jboss-as-web-7.1.1.Final.jar:7.1.1.Final
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) rt.jar:1.7.0_55
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) rt.jar:1.7.0_55
at java.lang.Thread.run(Thread.java:745) rt.jar:1.7.0_55
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set db/migration/changelog-initial.xml::1435731060394-8::deepavs (genera
ted):
Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near ') NULL, longitude DOUBLE(22) NULL, createdBy VARCHAR(255) NULL, CONSTRAINT PK_CO' at line 1 [Failed SQL: CREATE TABLE mds_prod_
temp.coordinate (id BIGINT AUTO_INCREMENT NOT NULL, dateCreated datetime NOT NULL, lastModified datetime NOT NULL, revision BIGINT NULL, uuid VARCHAR(255) NO
T NULL, version BIGINT NULL, latitude DOUBLE(22) NULL, longitude DOUBLE(22) NULL, createdBy VARCHAR(255) NULL, CONSTRAINT PK_COORDINATE PRIMARY KEY (id))]
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:584) [liquibase-core-3.4.0.jar:]
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51) [liquibase-core-3.4.0.jar:]
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) [liquibase-core-3.4.0.jar:]
at liquibase.Liquibase.update(Liquibase.java:208) [liquibase-core-3.4.0.jar:]
at liquibase.Liquibase.update(Liquibase.java:188) [liquibase-core-3.4.0.jar:]
at liquibase.integration.servlet.LiquibaseServletListener.executeUpdate(LiquibaseServletListener.java:237) [liquibase-core-3.4.0.jar:]
at liquibase.integration.servlet.LiquibaseServletListener.contextInitialized(LiquibaseServletListener.java:118) [liquibase-core-3.4.0.jar:]_*
I have this table in MySQL:
CREATE TABLE IF NOT EXISTS `Campaign` (
`IdCampaign` int(11) NOT NULL AUTO_INCREMENT,
`CPM` double DEFAULT NULL,
PRIMARY KEY (`IdCampaign`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
When I run `liquibase generateChangeLog`, it generates this xml:
<changeSet author="gavriel (generated)" id="1396268443940-9">
<createTable tableName="Campaign">
<column autoIncrement="true" name="IdCampaign" type="INT(10)">
<constraints primaryKey="true"/>
</column>
<column name="CPM" type="DOUBLE(22)"/>
</createTable>
</changeSet>
But then running `liquibase --logLevel=debug update` on a new, empty DB, I get this error:
DEBUG 3/31/14 4:31 PM:liquibase: changelog.xml: 1396268443940-9::gavriel (generated): Executing EXECUTE database command: CREATE TABLE test2.Campaign (IdCampaign INT(10) AUTO_INCREMENT NOT NULL, CPM DOUBLE(22) NULL, CONSTRAINT PK_CAMPAIGN PRIMARY KEY (IdCampaign))
SEVERE 3/31/14 4:31 PM:liquibase: changelog.xml: 1396268443940-9::gavriel (generated): Change Set changelog.xml::1396268443940-9::gavriel (generated) failed. Error: Error executing SQL CREATE TABLE test2.Campaign (IdCampaign INT(10) AUTO_INCREMENT NOT NULL, CPM DOUBLE(22) NULL, CONSTRAINT PK_CAMPAIGN PRIMARY KEY (IdCampaign)): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL, CPM DOUBLE(22) NULL, CONSTRAINT PK_CAMPAIGN PRIMARY' at line 1
liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE test2.Campaign (IdCampaign INT(10) AUTO_INCREMENT NOT NULL, CPM DOUBLE(22) NULL, CONSTRAINT PK_CAMPAIGN PRIMARY KEY (IdCampaign)): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL, CPM DOUBLE(22) NULL, CONSTRAINT PK_CAMPAIGN PRIMARY' at line 1