1

I have a spring roo hibernate project and a MySql database and I want to use liquibase for managing migrations.

I generated the initial changelog and did a changelogSync to mark all the changelogs as applied. Now when i did a diff (without modifying anything), I expected the diff to be empty. However it dropped all the existing tables and created new ones with different names.

Eg. One sample changeSet with generateChangeLog:

<changeSet author="author (generated)" id="1437392254522-37">
    <createTable tableName="user_roles">
        <column name="user" type="BIGINT(19)">
            <constraints nullable="false"/>
        </column>
        <column name="roles" type="BIGINT(19)">
            <constraints nullable="false"/>
        </column>
    </createTable>
</changeSet> 

changeSet with diff:

<changeSet author="author (generated)" id="1437395711084-26">
    <createTable tableName="User_Role">
        <column name="User_id" type="BIGINT">
            <constraints nullable="false"/>
        </column>
        <column name="roles_id" type="BIGINT">
            <constraints nullable="false"/>
        </column>
    </createTable>
</changeSet>

Is there any setting that I am missing?

Kechit Goyal
  • 3,952
  • 3
  • 20
  • 21
  • That is very strange. Are you absolutely certain you are using the same database in both instances? If there were only case differences, that would be one thing, but I see differences in names also (user_roles vs User_Role). That makes me think there is something unusual going on. I would use an external tool like Squirrel SQL or MySqlAdmin to see if there are multiple databases/schemas in play here. – SteveDonie Jul 20 '15 at 16:12
  • A single database. I dropped the schema and used hibernate's hbm2ddl to generate the basic tables before running generateChangeLog and diff. – Kechit Goyal Jul 20 '15 at 18:05

1 Answers1

4

I had not specified the naming strategy in the reference url. I assumed that it would pick it up from the properties of the persistenceUnit.

So I modified

referenceUrl:hibernate:ejb3:persistenceUnit

To

 referenceUrl:hibernate:ejb3:persistenceUnit?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
Kechit Goyal
  • 3,952
  • 3
  • 20
  • 21