DISQUS

OLD4 Bamboo Blog: ActiveRecord != DataMapper

  • Jonathan Conway · 1 year ago
    DM's got classic migrations now (at least they're there in trunk)...
  • TomK32 · 1 year ago
    Jonathan, how good are Datamapper's migrations beyond the simple table creation? I mean like updating some counter cache I add at a later point?
  • Carl · 1 year ago
    One thing I don't understand about DataMapper is its usage of the terms property and attribute. When is something a property and when is it an attribute? This seems a little confusing.
  • Matt · 1 year ago
    @Jon, true there are migrations in trunk but I presume they are still destructive so what benefit over auto_migrate do they provide (other than a history, which would be in your version control system)?

    @Carl, I believe that a property defines an attribute, its type and the default value.
  • James Urquhart · 1 year ago
    I was actually quite impressed with DataMapper. The documentation made sense, and the overview on the website was quite informative.

    As for ActiveRecord, well i've had my ups and downs with that. The distinction between Model and the Migration was a bit annoying.

    For example, when manipulating my schema via the Migration, i often had the associated Model break. Which is great if you are on the previous version, but the more versions behind you are, the more things can go wrong when upgrading - especially if you rely on methods in your models, or you decide to use another database and find that what worked in MySQL in version 1 totally barfs up with SQLite.

    IMO, DataMapper is doing the right thing by sticking the schema in along with the model. That way i can think of versioning the Model as a whole.
  • Jonathan Conway · 1 year ago
    @carl - Properties are still attributes of a DM managed class however the difference is that DM manages their persistence.

    @Matt + @thomas - I'm pretty sure the classic migrations aren't destructive (well they can be if so wished, or I might have misunderstood:)). A DM migration is just a class that inherits DataMapper::Migration in a similar way to Rails migrations. You can manipulate and change your schema/data anyway you wish in the 'up' and 'down' methods just like you can in Rails. Is this what you mean?

    Cheers my dears

    Jonathan
  • Carl · 1 year ago
    @Matt & @Jonathan - Thanks for the explanation! DataMapper looks really cool and I'll try it out next time I start a merb app.
  • solnic · 1 year ago
    Hey, nice comparison, I noticed one issue, this:

    DataMapper::Base.auto_migrate!

    has been changed into this:

    DataMapper::Persistence.auto_migrate!

    Cheers!