Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

liquibase.exception.MigrationFailedException when importing generated XML files with dates #100

Closed
JoshBargar opened this issue Jan 25, 2023 · 6 comments

Comments

@JoshBargar
Copy link

JoshBargar commented Jan 25, 2023

Description of the Issue

I am using the API to generate a liquibase XML file, but when I execute mvn liquibase:update, the following error is logged:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.16.1:update (default-cli) on project test-liquibase: 
[ERROR] Error setting up or running Liquibase:
[ERROR] liquibase.exception.MigrationFailedException: Migration failed for changeset sql/1.0/00017-changes.xml::JailerExport::testuser:
[ERROR]      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 '.11, 2019-04-26-15.47.11, 0, 2019-01-01-00.00.00, 0.24)' at line 1 [Failed SQL: (1064) INSERT INTO testdb.rates (id, created, modified, version, effective_date, rate) VALUES ('2', 2019-04-26-15.47.11, 2019-04-26-15.47.11, 0, 2019-01-01-00.00.00, 0.24)]

XML file generated via API:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="JailerExport" author="testuser">
<insert tableName="rates">
<column name="id" value="1"/>
<column name="created" valueDate="2019-04-26-15.47.11"/>
<column name="modified" valueDate="2019-04-26-15.47.11"/>
<column name="version" valueNumeric="0"/>
<column name="effective_date" valueDate="2019-01-01-00.00.00"/>
<column name="rate" valueNumeric="0.24"/>
</insert>
</changeSet>
</databaseChangeLog>

Expected Behavior

The insert will work if the "value" attribute is used instead of "valueDate": <column name="created" value="2019-04-26-15.47.11"/>

@JoshBargar JoshBargar changed the title liquibase.exception.MigrationFailedException when running generated XML files with dates liquibase.exception.MigrationFailedException when importing generated XML files with dates Jan 25, 2023
@Wisser
Copy link
Owner

Wisser commented Jan 25, 2023

Thanks for the issue report.

According to the documentation page:
https://docs.liquibase.com/change-types/nested-tags/column.html
Liquibase expects something like 'YYYY-MM-DDThh:mm:ss' as the value of a "valueDate" attribute.

This is not quite what Jailer generates. Could you please check if the following can be imported?

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="JailerExport" author="testuser">
<insert tableName="rates">
<column name="id" value="1"/>
<column name="created" valueDate="2019-04-26T15.47.11"/>
<column name="modified" valueDate="2019-04-26T15.47.11"/>
<column name="version" valueNumeric="0"/>
<column name="effective_date" valueDate="2019-01-01T00.00.00"/>
<column name="rate" valueNumeric="0.24"/>
</insert>
</changeSet>
</databaseChangeLog>

Thanks in advance,
Ralf

@JoshBargar
Copy link
Author

JoshBargar commented Jan 25, 2023

The following error is logged:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.16.1:update (default-cli) on project test-liquibase: 
[ERROR] Error setting up or running Liquibase:
[ERROR] liquibase.exception.MigrationFailedException: Migration failed for changeset sql/1.0/00017-changes.xml::JailerExport::testuser:
[ERROR]      Reason: liquibase.exception.DatabaseException: Unknown column '26T15.47.11' in 'field list' [Failed SQL: (1054) INSERT INTO testdb.rates (id, created, modified, version, effective_date, rate) VALUES ('1', 2019-04-26T15.47.11, 2019-04-26T15.47.11, 0, 2019-01-01T00.00.00, 0.24)]

This changeset is successful, though:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="JailerExport" author="testuser">
<insert tableName="rates">
<column name="id" value="1"/>
<column name="created" valueDate="2019-04-26T15:47:11"/>
<column name="modified" valueDate="2019-04-26T15:47:11"/>
<column name="version" valueNumeric="0"/>
<column name="effective_date" valueDate="2019-01-01T00:00:00"/>
<column name="rate" valueNumeric="0.24"/>
</insert>
</changeSet>
</databaseChangeLog>

@Wisser
Copy link
Owner

Wisser commented Jan 25, 2023

Where is the difference between the changeSet I asked you to test and this one?

@JoshBargar
Copy link
Author

The valueDate pattern you provided separates the time by . whereas the one that passed uses :.

@Wisser
Copy link
Owner

Wisser commented Jan 25, 2023

OMG, now I see that too. Please excuse my temporary blindness.

It's good that there is no need to fall back to "value" attribute. That would probably cause problems with other DBMS. Liquibase can obviously handle a date in the format it expects correctly.

I will correct this ASAP. I plan to release a new version at the end of the week. This issue will be fixed in the new version too.

@Wisser Wisser closed this as completed in 8c8cd31 Jan 26, 2023
@Wisser Wisser reopened this Jan 26, 2023
@Wisser
Copy link
Owner

Wisser commented Jan 28, 2023

Fixed in Release 14.2

@Wisser Wisser closed this as completed Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants