我以前的版本使用grails-database-migration插件一段时间,从来没有任何大问题。然而,最近我升级了整个项目的Grails 3.0.9,并做了一些额外的开发,该行为如下:grails升级到grails后数据库迁移插件问题3
进口当前督促DB结构到本地机器(即DB副本是没有的最新变化和新的实体)
执行:
grails -Dgrails.env=staging dbm-gorm-diff changlog.xml
我预计在这一点上什么是与现有实体和新的所有更改新changlog.xml文件。
我得到什么:
另外,如果我尝试运行grails -Dgrails.env=staging run-app
ERROR grails.boot.GrailsApp - Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springLiquibase_dataSource': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: liquibase.integration.spring.SpringLiquibase.createDatabase(Ljava/sql/Connection;Lliquibase/resource/ResourceAccessor;)Lliquibase/database/Database; FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':bootRun'. Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 ...
...
- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. | Error Failed to start server (Use --stacktrace to see the full trace)
这里是我的应用程序的一部分.yml
dataSource:
pooled: true
url: jdbc:mysql://127.0.0.1:3306/triz?useUnicode=yes&characterEncoding=UTF-8
driverClassName: "com.mysql.jdbc.Driver"
jmxExport: true
username: root
password: password
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2
environments:
development:
dataSource:
dbCreate: create
# url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
staging:
dataSource:
url: jdbc:mysql://127.0.0.1:3306/triz_staging?useUnicode=yes&characterEncoding=UTF-8
和gradle.build
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenCentral()
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0'
// classpath 'com.bertramlabs.plugins:less-asset-pipeline:2.6.7'
classpath "org.grails.plugins:hibernate:4.3.10.5"
classpath 'org.grails.plugins:database-migration:2.0.0.RC4'
}
}
...
...
dependencies {
...
compile 'org.liquibase:liquibase-core:3.3.2'
runtime 'org.grails.plugins:database-migration:2.0.0.RC4'
}
UPDATE 我有另一种方式来解决这个问题: 我的计划是基于我目前的PROD数据库更新日志,然后生成我做出改变的差异。听起来简单直接;然而,它没有按预期工作。下面是我做的:
- 甩刺DB
- 删除liquibase表
- 运行:
grails dbm-generate-changelog changelog-init.xml --add
在这一点上,我预计的changelog-导入init.xml包含DB的当前状态。但是,它首先应用了基于我的模型的更改,然后尝试生成差异。最后,我结束了一个更改日志,其中包括我的整个现有数据库,其中应用了来自gorm的更改。
我在这里做错了什么?
补充意见
它看起来像,每当我尝试运行任何迁移相关的命令是,Grails应用之前,所有的变化,甚至通过我的配置说:
staging:
dataSource:
dbCreate: ~
url: jdbc:mysql://127.0.0.1:3306/triz_staging?useUnicode=yes&characterEncoding=UTF-8
properties:
jmxEnabled: true
而且完全试过删除dbCreate
。没有改变任何东西... 我完成了,不知道下一步移动到哪里!