Liquibase SQL文件不起作用并引发语法错误

时间:2018-12-11 13:15:29

标签: mysql liquibase liquibase-sql

我正在使用mysql 8.0.x,并尝试使用liquibase版本3.6.2来应用更改日志。

当我尝试通过命令行更新changelog时,它在yaml格式下工作正常,但sql格式不适用于changeset。

Here是整个设置。 command-to-run.bat文件是我要触发的确切命令。

我认为问题与this相同,但是该解决方案也不起作用。他们的问题是文件改写不应该是UTF-8 BOM格式,尽管该问题已解决,但我尝试更改格式,但仍然遇到问题。

我正在使用liquibase给出的示例相同的sql文件。我收到的错误是

Unexpected error running Liquibase: 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 '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1 [Failed SQL: --liquibase formatted sql

--changeset bob:1
create table item (
  id int not null primary key,
  name varchar(255) not null,
  description varchar(255)
)]
liquibase.exception.MigrationFailedException: Migration failed for change set changelog-master.xml::third::akshay:
     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 '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1 [Failed SQL: --liquibase formatted sql

--changeset bob:1
create table item (
  id int not null primary key,
  name varchar(255) not null,
  description varchar(255)
)]
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:637)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:78)
        at liquibase.Liquibase.update(Liquibase.java:202)
        at liquibase.Liquibase.update(Liquibase.java:179)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1205)
        at liquibase.integration.commandline.Main.run(Main.java:191)
        at liquibase.integration.commandline.Main.main(Main.java:129)
Caused by: 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 '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1 [Failed SQL: --liquibase formatted sql

--changeset bob:1
create table item (
  id int not null primary key,
  name varchar(255) not null,
  description varchar(255)
)]
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:356)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:57)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:125)
        at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1229)
        at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1211)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:600)
        ... 7 common frames omitted
Caused by: java.sql.SQLSyntaxErrorException: 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 '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:782)
        at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:666)
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:352)
        ... 12 common frames omitted


For more information, please use the --logLevel flag

0 个答案:

没有答案