Loading data with migrations


#1

Hello,

I’m just taking a look at migrations, seems like a fantastic way to
maintain
the database. I am wonder if there is a way to maintain what I’ll call
“reference data” along with the migrations. A lot of times in apps your
have tables that have pretty static data, often used to generate select
lists. Is there a way to insert the reference data into these tables
using
migrations?


#2

Nevermind, RTFM

class AddSystemSettings < ActiveRecord::Migration
def self.up
create_table :system_settings do |t|
t.column :name, :string
t.column :label, :string
t.column :value, :text
t.column :type, :string
t.column :position, :integer
end

  SystemSetting.create :name => "notice", :label => "Use notice?",

:value => 1
end


#3

http://wiki.rubyonrails.com/rails/pages/UnderstandingMigrations

About three quarters of the way down that page is a brief mention of
adding look up data from a migration.

Anthony