简体   繁体   English

没有应用Grails数据库迁移

[英]Grails db migration not being applied

I am using Grails 2.4.3 and the database-migration:1.4.0 plugin. 我正在使用Grails 2.4.3和database-migration:1.4.0插件。

I have created a simple Domain class called Mod. 我创建了一个简单的Domain类,称为Mod。 I am able to create the groovy based changelog using dbm-generate-gorm-changelog changelog.groovy . 我可以使用dbm-generate-gorm-changelog changelog.groovy创建基于groovy dbm-generate-gorm-changelog changelog.groovy This correctly generates the file. 这样可以正确生成文件。 I then execute dbm-update which reports: 然后,我执行dbm-update报告:

|Starting dbm-update for database sa @ jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000
|Finished dbm-update

However, there are no table created in the database and running dvm-status returns: 但是,数据库中没有创建任何表,并且运行dvm-status返回:

|Starting dbm-status for database sa @ jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
1 change sets have not been applied to SA@jdbc:h2:mem:devDb
     changelog.groovy::1413897188349-1::clarkrichey (generated)
|Finished dbm-status 

My development environment configuration from DataSource.groovy is as follows: 来自DataSource.groovy的我的开发环境配置如下:

 development {
        dataSource {
//            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
    }

The issue centers around the fact you are using an in-memory instance of h2. 问题围绕着您正在使用h2的内存实例这一事实。 Thus, nothing is saved between application launches. 因此,在应用程序启动之间不保存任何内容。 If you want a persistent database then change your url to use a file based instance. 如果您想要一个持久数据库,则将您的URL更改为使用基于文件的实例。

development {
  dataSource {
    dbCreate = "none" // one of 'create', 'create-drop', 'update', 'validate', ''
    url = "jdbc:h2:file:/path/to/save/to/devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM