Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails Data Base Migration - dbm-gorm-diff is not working

I am using Grails 2.3.5 with database migration plugin in new project for understand how it is working. But sometimes dbm-gorm-diff provide empty changelog file,even changes is there. For example,

i have the person domain class with out any properties. When initially creating change log, it will create 2 fields id and version in change log. After that, added 2fields name,age into that person class. then did dbm-update and dbm-gorm-diff that give like following.

databaseChangeLog = { }

Sometimes gives the changes. some times is not working. Please help me. Why it is working like that. Sorry for bad english.

like image 200
Visme Avatar asked Dec 12 '25 15:12

Visme


2 Answers

Using the following tutorial works for me. Make sure you remove dbCreate from your DataSource.groovy. According to the tutorial the workflow is as follows:

Setup

  1. Remove dbCreate from DataSource.groovy
  2. Initially run grails dbm-generate-gorm-changelog changelog.groovy
  3. Sync the changelog with your db by running grails dbm-changelog-sync

Changing domain

  1. Change domain class
  2. Run grails dbm-gorm-diff <your-filename>.groovy --add
  3. Run grails dbm-changelog-sync

Hope this helps

like image 172
saw303 Avatar answered Dec 15 '25 07:12

saw303


I have spent some time searching for the answer to this same issue.

Caveat: I am using the Grails interactive shell to issue commands, including the dbm-* commands.

By brute force alone, I have come to the conclusion that the domain classes are not reliably reloading. To get consistent results (especially with the generation of new changeLog files), any time I modify a domain class, I stop and restart the Grails interactive shell before calling dbm-gorm-diff. I've tried issuing other commands like clean, compile, package and refresh-dependencies and they just aren't working, and the -reloading flag at the start up of the Grails interactive shell doesn't seem to make any difference either.

Restarting the Grails interactive shell, however, does seem to work reliably, thought it galls me to do so :)

Those who do not use the interactive shell should not be having this problem since the domain classes are loaded with every command call.

like image 24
David Vezzani Avatar answered Dec 15 '25 07:12

David Vezzani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!