#68 √ resolved
Aaron Wheeler

DataMapper models corruption in Specs and Rake tasks

Reported by Aaron Wheeler | March 6th, 2008 @ 04:10 PM

At some point after Merb.start is called, the models become corrupted so that only an empty shell of a model remains.

The symptoms are when running rake dm:db:automigrate, all of the tables are created but none of the columns are.

Also, when running tests, running DataMapper::Persistence.auto_migrate! will fail similarly, and instance methods on the models will disappear.

Here is an example of a simple application that experiences this problem.

http://pastie.caboo.se/161797

A temporary fix seems to be to reload the models after Merb has started. See this fix for the rake issue:

http://pastie.caboo.se/162293

Comments and changes to this ticket

  • Simon Rand

    Simon Rand March 6th, 2008 @ 11:48 PM

    I've been working on this one for the last couple of hours, the rake dm:db:automigrate task isn't passing the properties to be migrated for a given model.

    If you run DataMapper::Persistable.auto_migrate! (Persistable rather than Persistent if you are using the latest DataMapper code from GitHub) everything works fine.

    The fix you've supplied works but I want to look into this more, it's odd considering they are calling the same task, one is just called manually..

  • Simon Rand

    Simon Rand March 6th, 2008 @ 11:52 PM

    Just to confirm the fix works only for previously migrated models, running the rake task with the fix seems to run the migration 3 times, only the first time correctly creating the tables.

  • Simon Rand

    Simon Rand March 7th, 2008 @ 09:27 PM

    After pulling down all the new code for datamapper, merb_datamapper and merb core this problem seems to have been corrected on my end..

  • Aaron Wheeler

    Aaron Wheeler March 8th, 2008 @ 09:45 AM

    When you say new code for datamapper, which version are you talking about? DataMapper::Persistable I think is something that isn't introduced until 0.3, which I don't believe is stable.

  • Simon Rand

    Simon Rand March 8th, 2008 @ 05:41 PM

    I'm talking about the latest (you're correct not stable) edge code from the DM GitHub at http://github.com/sam/dm/tree/ma...

    Note: All your Models should now inherit from DataMapper::Model

    I've yet to test specs and look into why this has fixed but everything seems fine here..

  • Fabien Franzen (loob2)
  • Michael Klishin (antares)

    Michael Klishin (antares) May 8th, 2008 @ 08:07 PM

    • → State changed from “new” to “resolved”
    • → Assigned user changed from “” to “Michael Klishin (antares)”

    Seems to be fixed in HEAD of merb_datamapper (in dm-more now) and dm-core. Reoped if it is not so.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins