Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8137469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:07:58+00:00 2026-06-06T11:07:58+00:00

Using Grails database-migration I have a table in production defined like so: +————–+————+——+—–+———+—————-+ |

  • 0

Using Grails database-migration I have a table in production defined like so:

+--------------+------------+------+-----+---------+----------------+
| Field        | Type       | Null | Key | Default | Extra          |
+--------------+------------+------+-----+---------+----------------+
| id           | bigint(20) | NO   | PRI | NULL    | auto_increment |
| version      | bigint(20) | NO   |     | NULL    |                |
| basket_id    | bigint(20) | NO   | MUL | NULL    |                |
| gift_card_id | bigint(20) | NO   | MUL | NULL    |                |
+--------------+------------+------+-----+---------+----------------+

In the latest develop branch we’ve modified this domain to use a composite key and remove the id and version:

class BasketGiftCard implements Serializable {

  Basket basket
  GiftCard giftCard

  static mapping = {
    id composite: ['basket', 'giftCard']
    version false
  }
}

When running the dbm-gorm-diff we end up with the following:

changeSet(author: "gdboling (generated)", id: "1340670757336-8") {
    addPrimaryKey(columnNames: "basket_id, gift_card_id", constraintName: "basket_gift_cPK", tableName: "basket_gift_card")
}

changeSet(author: "gdboling (generated)", id: "1340670757336-16") {
    dropPrimaryKey(tableName: "basket_gift_card")
}

changeSet(author: "gdboling (generated)", id: "1340670757336-188") {
    dropColumn(columnName: "id", tableName: "basket_gift_card")
}

changeSet(author: "gdboling (generated)", id: "1340670757336-189") {
  dropColumn(columnName: "version", tableName: "basket_gift_card")
}

What’s interesting (and wrong) about this is the order. The dropPrimaryKey should go first, then everything else. As is, when running dbm-update, it fails.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:08:00+00:00Added an answer on June 6, 2026 at 11:08 am

    You have come across one of the problems with database diffs, albeit slightly different than the example given in that post. The migration plugin documentation was definitely not joking when it said:

    When running migration scripts on non-development databases, it’s important that you backup the database before running the migration in case anything goes wrong. You could also make a copy of the database and run the script against that, and if there’s a problem the real database will be unaffected.

    There have been several times that I needed to make manual adjustments to changelogs that were generated with dbm-gorm-diff. I think it just comes with the territory, unfortunately. That’s not to take anything away from the plugin though; it’s not perfect but I feel a lot more confident about my database structure since I started using it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using the Grails database-migration plugin during development of my application, and
We have developed a Web Application using grails, groovy and oracle as database with
I'm using Grails 1.3.7 + MySQL 5.5 + Liquibase through the database-migration plugin 0.2.1.
I'm using an H2 database for testing my Grails app. I have some simple
When using Grails 1.1 together with a MySQL the charsets of the auto-generated database
We are using Grails with a legacy database and we need to control how
I plan to build a database management system using Grails as the main framework.
I'm considering using Grails for my current project. I have a couple of requirements
Background: we have a Grails 1.3.7 app and are using Liquibase to manage our
Using mongodb in grails i am trying to get a hold of the database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.