mysql - MyBatis 迁移 : migrate up causes org. apache.ibatis.jdbc.RuntimeSqlException

标签 mysql mybatis

我刚刚安装了 Mybatis Migration并关注了他们的instructions . init、new、status 命令有效,但“向上迁移”导致以下错误:

------------------------------------------------------------------------
-- MyBatis Migrations - up
------------------------------------------------------------------------
========== Applying: 20140410190604_create_changelog.sql =======================
Error executing: --  Create Changelog

-- Default DDL for changelog table that will keep
-- a record of the migrations that have been run.

-- You can modify this to suit your database before
-- running your first migration.

-- Be sure that ID and DESCRIPTION fields exist in
-- BigInteger and String compatible fields respectively.

CREATE TABLE CHANGELOG (
ID NUMERIC(20,0) NOT NULL,
APPLIED_AT VARCHAR(25) NOT NULL,
DESCRIPTION VARCHAR(255) NOT NULL
);

ALTER TABLE CHANGELOG
ADD CONSTRAINT PK_CHANGELOG
PRIMARY KEY (id);

.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'ALTER TABLE CHANGELOG
ADD CONSTRAINT PK_CHANGELOG
PRIMARY KEY (id)' at line 18
------------------------------------------------------------------------
-- MyBatis Migrations FAILURE
-- Total time: 0s
-- Finished at: Thu Apr 10 15:08:51 PDT 2014
-- Final Memory: 12M/479M
------------------------------------------------------------------------

ERROR: Error executing command.  Cause: org.apache.ibatis.jdbc.RuntimeSqlException: Error executing: --  Create Changelog

-- Default DDL for changelog table that will keep
-- a record of the migrations that have been run.

-- You can modify this to suit your database before
-- running your first migration.

-- Be sure that ID and DESCRIPTION fields exist in
-- BigInteger and String compatible fields respectively.

CREATE TABLE CHANGELOG (
ID NUMERIC(20,0) NOT NULL,
APPLIED_AT VARCHAR(25) NOT NULL,
DESCRIPTION VARCHAR(255) NOT NULL
);

ALTER TABLE CHANGELOG
ADD CONSTRAINT PK_CHANGELOG
PRIMARY KEY (id);

.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'ALTER TABLE CHANGELOG
ADD CONSTRAINT PK_CHANGELOG
PRIMARY KEY (id)' at line 18

20140410190604_create_changelog.sql 文件中迁移生成的两个mysql DDL(create table 和alter table)。但是,如果我手动运行 sql,它不会提示任何语法错误。

什么可能导致这个“向上迁移”问题?

The script is like:

CREATE TABLE CHANGELOG (
ID NUMERIC(20,0) NOT NULL,
APPLIED_AT VARCHAR(25) NOT NULL,
DESCRIPTION VARCHAR(255) NOT NULL
);

ALTER TABLE CHANGELOG
ADD CONSTRAINT PK_CHANGELOG
PRIMARY KEY (id);

最佳答案

enviornment.properties 文件中设置 send_full_script=false 可以解决这个问题。

关于mysql - MyBatis 迁移 : migrate up causes org. apache.ibatis.jdbc.RuntimeSqlException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23000085/

相关文章:

php - WHERE 和 WHERE 或 WHERE Laravel 查询?

javascript - 我正在用选择的数据填充文本框,它可以工作,但是

mysql - spring、mysql、mybatis测试

java - MyBatis java 和 MySql 局部变量

PHP/SQL PDO 准备/执行插入语句不起作用

php - 使用正则表达式返回 mysql 字符串

mysql - 从连接表中查询日期列

java - 使用MyBatis Generator,当提供NULL值时如何为列指定默认值?

java - mybatis 列名冲突?

spring - 如何使用spring在postgresql中锁定表