Don't know how to query for sequences on MariaDB
See original GitHub issueEnvironment
Liquibase Version: 4.0.0
Liquibase Integration & Version: CLI
Liquibase Extension(s) & Version: NO
Database Vendor & Version:
docker official mariadb (image-id: 22851c7fe916
)
mariadb --version: mariadb Ver 15.1 Distrib 10.5.4-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
jdbc driver: org.mariadb.jdbc:mariadb-java-client:2.6.1
Operating System Type & Version: Ubuntu 20.04 LTS (Focal Fossa)
Description
Liquibase 4.0.0 is able to write sequences into the mariadb instance, but it can’t query the sequences when it is attempting to loadUpdateData
into the table.
The issue is related to the class liquibase.snapshot.jvmSequenceSnapshotGenerator
, in the method getSelectSequenceSql
MariaDB query isn’t implemented there. It should add something like this:
} else if (database instanceof MariaDBDatabase) {
return "SELECT TABLE_NAME AS SEQUENCE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='SEQUENCE' AND TABLE_SCHEMA='" + schema.getName() + "'"
} else {
throw new UnexpectedLiquibaseException("Don't know how to query for sequences on " + database);
}
Steps To Reproduce
test_table.csv
id_test, test_text
1, text 1
2, text 2
3, text 3
changelog-test.yml
databaseChangeLog:
- changeSet:
id: test-seq
author: test
changes:
- createSequence:
sequenceName: seq_test
- changeSet:
id: test-table
author: test
changes:
- createTable:
tableName: test_table
columns:
- column:
name: id_test
type: bigint
constraints:
primaryKeyName: pk_test_table
primaryKey: true
nullable: false
- column:
name: test_text
type: nvarchar(100)
- changeSet:
id: test-seq-default
author: test
changes:
- addDefaultValue:
tableName: test_table
columnName: id_test
columnDataType: bigint
defaultValueSequenceNext: seq_test
- changeSet:
id: test-dml
author: test
changes:
- loadUpdateData:
tableName: test_table
primaryKey: id_test
file: test_table.csv
encoding: UTF-8
relativeToChangelogFile: true
$ docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=your_password mariadb
$ java -jar liquibase.jar --changeLogFile changelog-test.yml --url "jdbc:mariadb://localhost/mysql" --username root --password "your_password" update
Actual Behavior
Error message:
Unexpected error running Liquibase: Migration failed for change set changelog-test.yml::test-dml::test:
Reason: liquibase.exception.UnexpectedLiquibaseException: Don't know how to query for sequences on root @ jdbc:mariadb://localhost/mysql (Default Schema: mysql)
For more information, please use the --logLevel flag
Expected/Desired Behavior
Conclude the loadUpdateData
without issues.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top GitHub Comments
It’s related. But the pushed code isn’t part of the version 4.0.0. I think we should try to bring these changes to v4 and test them.
Looks like it got fixed for liquibase
4.15
. Try upgrading your liquibase version to latest, if this doesnt fix your issue, please try to re-open the issue and we will look into it again. Thanks!