[Ruby] AR migration problems? was: refactoring/drying help
Ryan Davis
ryand-ruby at zenspider.com
Fri Oct 12 13:12:54 PDT 2007
On Oct 12, 2007, at 13:05 , Jack Danger Canty wrote:
> def self.up
> orphaned_listings = Account.find(:all, :conditions =>
> 'logged_in_at is not
> null').sites.map {|site| site.listings.find(:all, :conditions =>
> 'owner_id
> is null') }
> end
>
> About 50 migrations later I'd changed the conditions for
> logged_in_at, the
> sites association had been renamed and listings was now one level
> removed
> from sites (there was an additional join model). Urgh.
So?
At the point in time of the migration, it is perfectly valid.
The only thing you need is to have the model represented at all.
Later changes will do nothing to affect that. The _worst_ I've had to
do is define a couple model classes (to deal with renames) and add a
couple relations (so I could do something like the above with #sites).
More information about the Ruby
mailing list