Mar 21, 2009

DataMapper - some tiny issues within 0.9.9

I am working on a home-grown authorization system. It is very customized for our special requirement. I have to hack DataMapper to get the job done. The more I dig in DM, the more I love it. I can't imagine how much code I have to write to do the same thing if I do it with Java. As a relative new ORM framework, it sure has some corners that might not work well for you, following are some thing I found out in one day:

1. auto_migrate! vs. auto_upgrade!
class Employee
include DataMapper::Resource
property :id, Serial
property :name, String
...
end
class Manager < Employee
property :position, String, :default => 'manager'
...
end
Manager.auto_migrate!
the table will have following columns:
id
name
Manger.auto_upgrade!
the table will have following columns:
id
name
position