ref: master
db/migrate/20110221195242_create_units_and_add_reference_to_it_at_products_and_inputs.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
class CreateUnitsAndAddReferenceToItAtProductsAndInputs < ActiveRecord::Migration def self.up create_table :units do |t| t.string :singular, :null => false t.string :plural, :null => false t.integer :position t.references :environment, :null => false end [:products, :inputs].each do |table_name| change_table table_name do |t| t.remove :unit t.references :unit end end end def self.down drop_table :units [:products, :inputs].each do |table_name| change_table table_name do |t| t.string :unit t.remove_references :unit end end end end |