Which ORM is best to use with a new Rails 3 app against a legacy MySQL 5.1 database? I do not expect to ever run a migration against this database (though the schema may change from time to time), but I will certainly be writing to it.
-
Can you share a bit of the schema? – rwilliams Nov 14 '10 at 00:15
-
Sorry, it is the intellectual property of a client, so I can't share it. – Mark Richman Nov 14 '10 at 03:03
2 Answers
I may be biased towards DataMapper, but I think DM is generally a good option for integrating with legacy databases.
DM allows you to map meaningful model and property names to cryptic legacy table and column naming conventions. It allows you to do so either on a per model/property, or an app wide basis.
DM supports lazy properties, that will only be fetched when actually accessed.
DM has seamless support for composite primary keys.
DM only cares about the properties (columns) you explicitly declare in your models. Other columns will never be touched or read.
DM works nice with foreign key constraints in your database and with the help of dm-constraints it also supports creating them.
There's some documentation on http://datamapper.org/docs/legacy too.

- 481
- 3
- 6
There is also the dm-types-legacy library (https://github.com/postmodern/dm-types-legacy) which provides common DM Types for mapping in oddly formatted data (Numeric IP Addresses, HTML/URI encoded text, Date/Time strings).

- 51
- 1
-
1Does any of this work with datetime_select? For example, I am trying to update a datetime field and it fails because of this: "published_at(1i)"=>"2010", "published_at(2i)"=>"11", "published_at(3i)"=>"14", "published_at(4i)"=>"07", "published_at(5i)"=>"59" – Mark Richman Nov 15 '10 at 22:14