I have 4 related migrations in my Rails app:
First 3 migrations create one table each in the self.up and and drops them in their respective self.down methods.
4th migration runs a rake task that loads data to all three (in self.up). I am thinking what to put in self.down of this migration to delete the rows from the 3 tables?
Am I doing it wrong? Probably should have created one migration where I create 3 tables and load the data in self.up and just drop all three tables in the self.down method?
This is wrong!
Migrations should be used only for migrating your Data Model not your Data.
Rails 2.3.4 adds ‘seeds’. This is a file in db/seeds.rb contains ruby code to ‘bootstrap’ your database. This is a great way to create semi-static content for your database like categories, look-up tables or user accounts.
You can then load the seed data with a simple rake task