I’m trying to follow the tutorial here.
I have declared the dependency for the database migration plugin in my BuildConfig.groovy file with runtime ":database-migration:1.0" and then compiled. I have also comment out the dbCreate line of my production settings in my DataSource.groovy file. My production database is empty with no tables in it.
I then try to run the two commands to generate my initial change log:
grails dbm-create-changelog
grails prod dbm-generate-gorm-changelog --add changelog-1.0.groovy
The problem is the first command creates tables in my development database, not my production database. Then the second command fails to create the changelog-1.0.groovy file it is supposed to create (I assume) because the production database never had any tables created. I get several errors that say Hibernate failed to index the database and I a bunch of errors like this:
| Error 2012-07-10 08:40:28,704 [Compass Gps Index [pool-11-thread-2]] ERROR util.JDBCExceptionReporter - Table 'mygrailsapp_prod.some_class' doesn't exist
Even when I comment out my development settings in my DataSource.groovy file Grails is still looking for my development database. I should point out though if I drop the prod off the second command a the changelog-1.0.groovy file generates fine, though I am unclear if will somehow be messed up because it was generated off the development database (which had no tables in it until I ran the first command) instead of the production database.
What am I doing wrong here?
That’s probably because it is running against the development environment and you still have its dbCreate set to “update”
That’s not entirely accurate. From the link you posted it says after that step: “Note that your database will remain empty!” The database tables will only get created when you execute a dbm-update command. That’s when the changelog actually executes.
I think the blog you linked to isn’t entirely accurate on the prod switch for the second command. Nothing about your Domains is environment specific. So just leave that off and you should be able to keep going. I’m not sure why that error is being thrown. It really doesn’t make sense.