diffDatabaseToChangeLog with hibernate : db constraints dropped & recreated

I’ve just installed liquibase and got it running.

I ran diffDatabaseToChangeLog between by db running, mysql on mac osx.

I get a bunch of errors like this in the console:

    [diffDatabaseToChangeLog] Foreign key FK45838CEF45007F33 references table scraperresultlog, which we cannot find.  Ignoring.

The change log that is created has a drop statement and a corresponding create statement for every single foreign key.

It appears that this is because of the “references” clause in the db, has gone to lower case.
I verified that the schema on production is correct, but when I run the inserts on the mac they end up in lowercase.

This hasn’t caused a problem until now…

I figured it out. Even though the mac is a “unix” the file system is not case sensitive so mysql’s default is to use lower case table names…

In my.cnf set this value and things work much better.

lower_case_table_names=0

I take it back…

The errors on the console just went away…

I’m still getting the drops and creates.

This is one of the indexes it is wanting to drop and recreate.

    | AdvancedSearchParameters | CREATE TABLE `AdvancedSearchParameters` (  CONSTRAINT `FK49B85E14131AB944` FOREIGN KEY (`linkFoundDate_id`) REFERENCES `DateIntervalRestriction` (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |

Here’s the ChangeLog that gets created:

                   

       
           
       

Are you using 1.9 or the RC of 2.0?  There are some issues with the diff tool, I pushed changes to it out to 2.1 in order to get 2.0 out.  I generally consider the diff tool to be a crutch and not something to use as a major part of your dev cycle.  So, for example, you can use it to get a start of a changeSet when implementing liquibase on an existing database, but you will want to go back through what is generated and clean up what is nessisary.

Case sensitive databases is one issue we have outstanding.  Another is the foreign key/index issue.  The JDBC metadata we get is often vague about what is actually an index and which is an index that is part of a foreign key, that is something else I am going to have to go through and improve, probably adding some database-specific calls in there.

For now, you will probably have to hand fix up the changelog as needed by removing the dropIndex calls.

Nathan

I’m using 1.9.5