Grails在部署的服务器上迁移数据库 [英] Grails database migration on deployed server

查看:314
本文介绍了Grails在部署的服务器上迁移数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我遇到了一个问题/与grails数据库迁移插件混淆。

Hi everyone I am encountering a problem/confusion with grails database migration plugin.

用于学习的资源 -

Resources used for studying-


  1. 官方Grails数据库迁移插件文档 - http://grails-plugins.github.io/grails-database-migration/docs/manual/guide/introduction.html

  2. 数据库迁移示例 - http://grails.github.io/grails-howtos/en/manage数据库.html

  1. Official Grails Database Migration Plugin documentation- http://grails-plugins.github.io/grails-database-migration/docs/manual/guide/introduction.html
  2. Database migration example- http://grails.github.io/grails-howtos/en/manageDatabases.html

现在,借助这些我可以非常好地迁移或更改我的数据库

Now with the help of these I am very well able to migrate or do changes to my database on the local machine which has grails installed and working correctly.

问题是生产服务器是在线部署的,我总是上传我的WAR文件以在apache tomcat上部署。所以它基本上运行在JAVA上,因此grails没有安装在ubuntu机器上。
现在如何在服务器上迁移mysql数据库?

The problem is that the production server is deployed online and I always upload my WAR file to deploy on apache tomcat. So it basically runs on JAVA so grails is not installed on the ubuntu machine. Now how will I migrate mysql database on the server?

推荐答案

在Config.groovy文件中添加下面的config。迁移将在WAR部署期间运行。

Add below config in your Config.groovy file. Migration will run during WAR deployment.

//===========================DATA MIGRATION============================
//Run changelog.groovy during application deployment on server?
grails.plugin.databasemigration.updateOnStart = true
//File used to run the db migration scripts
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']
//Absolute path of changelog.groovy in the app base dir
grails.plugin.databasemigration.changelogLocation = 'migrations'
//  the default schema to use when running auto-migrate on start
//grails.plugin.databasemigration. updateOnStartDefaultSchema ='schema' // You may not need this in MYSQL
//=====================================================================

根据上述配置,这是您的文件夹结构:

Based on the above configuration, this is how your folder structure should be:

your-grails-project
      --migrations/
          --changelog.groovy
          --migration1.groovy
          --migration2.groovy

changelog.groovy

changelog.groovy

databaseChangeLog = { 
  include file: 'migration1.groovy'
  include file: 'migration2.groovy'
}    

这篇关于Grails在部署的服务器上迁移数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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