Firstly, we deleted the database and then ran our app with dbCreate="update"
to create a nice working base.
Then we ran:
grails dbm-generate-changelog baseline.xml
To create the script to generate our schema. We removed dbCreate=xxx
from the DataSource.groovy
and added the following in our Config.groovy
:
grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']
We then started our app, which created the DB, this time from the liquibase and all was good we thought.
Then we changed nothing (no changes to the source code), and did:
grails dbm-gorm-diff should_be_empty.xml --add
To our surprise, this generated 9 additional changeSets, all for indexes.
e.g:
<changeSet author="me(generated)" id="1438097433176-1">
<createIndex indexName="site_id_uniq_1438097432189" tableName="adobe_message_service_config" unique="true">
<column name="site_id"/>
</createIndex>
</changeSet>
<changeSet author="me(generated)" id="1438097433176-4">
<createIndex indexName="IX_note_player" tableName="note">
<column name="player_id"/>
</createIndex>
</changeSet>
Very strange, where did these changes come from? So we stopped and started the app again, and looked in the databasechangelog table and saw all 9 new changes sets had been run.
So we did this a second time, really expecting no changeSets:
grails dbm-gorm-diff should_be_empty_this_time.xml --add
and now it generated 5 change sets, all indexes again, all duplicates of the 9 it found before. Looking at the database itself, there is already an index with exactly the same name, table and column. So the database already has the change, and now the same duplicate change is in the changeSets twice, and we don't know why it was in the original baseline from dbm-generate-changelog
What is going on?