Database-migration fails when trying to drop primary keys, but only sometimes
===

Very odd situation.  I have a root changelog.groovy which is the current production database.  I also have a latest-changelog.groovy which is basically a diff with some minor diff corrections (because diff isn't perfect).

Starting with an empty database, the following works (**Scenario 1**):

 - mysqldump production database 
 - source into dev database 
 - remove include of latest-changelog.groovy 
 - execute dbm-changelog-sync 
 - add include of latest-changelog.groovy 
 - execute dbm-update

The following does not work (**Scenario 2**):

 - drop dev database
 - create empty dev database
 - execute dbm-update 

What happens is the initial changelog.groovy runs without a hitch.  But when it gets to the latest-changelog.groovy it fails with the following:

> Caused by: java.sql.SQLException: Error on rename of
> './main_dev/#sql-b4_2334' to
> './main_dev/book_project_note' (errno: 150)

I have a table defined like so:

    mysql> desc book_project_note;
    +---------------------------+------------+------+-----+---------+-------+
    | Field                     | Type       | Null | Key | Default | Extra |
    +---------------------------+------------+------+-----+---------+-------+
    | book_project_id           | bigint(20) | NO   | PRI | NULL    |       |
    | note_id                   | bigint(20) | NO   | PRI | NULL    |       |
    | book_project_note_type_id | bigint(20) | NO   | PRI | NULL    |       |
    +---------------------------+------------+------+-----+---------+-------+

The following changeset is what fails:

    changeSet(author: "gdboling (generated)", id: "1341248060406-80") {
      dropPrimaryKey(tableName: "book_project_note")
    }

What I'm trying to do here is drop the primary keys and then recreate 2 of them with the following:

    changeSet(author: "gdboling (generated)", id: "1341248060406-72") {
      addPrimaryKey(columnNames: "book_project_id, note_id", constraintName: "book_project_PK", tableName: "book_project_note")
    }

I'm wondering why it works with **Scenario 1** but fails in **Scenario 2**.