MyBatis迁移:向上迁移会导致org.apache.ibatis.jdbc.RuntimeSqlException [英] MyBatis Migrations: migrate up causes org.apache.ibatis.jdbc.RuntimeSqlException

查看:150
本文介绍了MyBatis迁移:向上迁移会导致org.apache.ibatis.jdbc.RuntimeSqlException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 Mybatis Migration ,并遵循了他们的

I just installed Mybatis Migration and followed their instructions. The init, new, status commands worked but "migrate up" causes the below error:

------------------------------------------------------------------------
-- 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(创建表和更改表).但是,如果我手动运行sql,则不会抱怨任何语法错误.

The two mysql DDL (create table and alter table) were generated by migrations in the file 20140410190604_create_changelog.sql. However, if I manually ran the sql it didn't complain any syntax error.

什么可能导致此迁移"问题?

What might causes this "migrate up" problem?

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可以解决此问题.

Setting send_full_script=false in enviornment.properties file fixes the problem.

这篇关于MyBatis迁移:向上迁移会导致org.apache.ibatis.jdbc.RuntimeSqlException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆