Skip to content

Instantly share code, notes, and snippets.

@tomoya55
Created December 7, 2009 10:25
Show Gist options
  • Select an option

  • Save tomoya55/250750 to your computer and use it in GitHub Desktop.

Select an option

Save tomoya55/250750 to your computer and use it in GitHub Desktop.
migration 1, :create_people_table do
up do
puts "up"
create_table :people do
column :id, Integer, :serial => true
column :name, String, :size => 50
column :age, Integer
end
end
down do
drop_table :people
end
end
migration 2, :add_extra_props_people do
up do
modify_table :people do
add_column :extra, String, :nullable? => true
end
end
down do
modify_table :people do
drop_column :extra
end
end
end
migration 3, :rename_age_to_birthyear do
up do
execute 'ALTER TABLE people CHANGE COLUMN `age` `birthyear` INTEGER DEFAULT 0'
end
down do
execute 'ALTER TABLE people CHANGE COLUMN `birthyear` `age` INTEGER DEFAULT 0'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment