Error with Database Migration not recognizing primary key

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Error with Database Migration not recognizing primary key

sethfuller
I am using Database Migration 1.0 with Grails 1.3.7 and MySql 5.5.
I have a table that already has a multiple column primary key defined on it. When I ran dbm-gorm-diff a statement was generated to define the primary key on the same two columns. When I ran this statement I got a MySql error "Multiple primary key defined", which I believe means the primary key was already defined, but the statement was trying to define another (even though actually the same) primary key for the table.

Strangely later in the same file generated by dbm-gorm-diff the primary key for the table is dropped. The table is a join table user_role with just the columns user_id and role_id which are both bigint unsigned.
Reply | Threaded
Open this post in threaded view
|

Re: Error with Database Migration not recognizing primary key

pledbrook
Administrator
> I am using Database Migration 1.0 with Grails 1.3.7 and MySql 5.5.
> I have a table that already has a multiple column primary key defined on it.
> When I ran dbm-gorm-diff a statement was generated to define the primary key
> on the same two columns. When I ran this statement I got a MySql error
> "Multiple primary key defined", which I believe means the primary key was
> already defined, but the statement was trying to define another (even though
> actually the same) primary key for the table.
>
> Strangely later in the same file generated by dbm-gorm-diff the primary key
> for the table is dropped. The table is a join table user_role with just the
> columns user_id and role_id which are both bigint unsigned.

I would raise an issue for this at
http://jira.grails.org/browse/GPDATABASEMIGRATION . It may or may not
be something that can be fixed, but a JIRA will ensure it's
investigated.

In the meantime, if it proves problematic you should probably consider
maintaining an extra database that you can diff against with dbm-diff.

Hope that helps,

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware
Reply | Threaded
Open this post in threaded view
|

Re: Error with Database Migration not recognizing primary key

sethfuller
I couldn't find a link on the Jira site to report an issue. Maybe I am missing something.


As I said in my original post the same file of changeSets later dropped the primary key. When I ran dbm-gorm-diff again it wanted to add the primary key again. When I ran dbm-update the add primary key succeeded. I ran dbm-gorm-diff again and it did not generate a changeSet to add the primary key again, so maybe it didn't understand something about the way the primary key was defined originally.
Reply | Threaded
Open this post in threaded view
|

Re: Error with Database Migration not recognizing primary key

pledbrook
Administrator
> I couldn't find a link on the Jira site to report an issue. Maybe I am
> missing something.

You need to register and log in before you can report issues.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware