I recall problems with putting data migrations directly into a
database migration file.
Where should I do them?

I need to run a few SQL queries on the database, and then delete a few
unnecessary things.
Something like this pseudo example:

#get ids of old softwares
old_ids = SELECT id FROM softwares WHERE name IN ('foo', 'bar');
good_id = SELECT id FROM softwares WHERE name = 'Good';

#get directories using old softwares
SELECT id, software_id FROM directories WHERE software_id IN
(old_ids.join(','));

#update these directories with new software
UPDATE directories SET software_id = good_id WHERE software_id IN
(old_ids.join(','));

#delete old softwares
DELETE from softwares WHERE id IN (old_ids.join(','));

There is no change to the database schema itself, should this be a
throw-away rake task or is can it be done as a "DATA ONLY" migration?




-- 
Anthony Ettinger
408-656-2473
http://anthony.ettinger.name

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to