Massive Cleanup
[cs356-p2-videostore.git] / db / migrate / 020_rebuild_merchandises_table.rb
1 class RebuildMerchandisesTable < ActiveRecord::Migration
2
3   # This whole thing is an awful way of doing a column rename
4
5   def self.up
6     drop_table :merchandises
7
8     create_table :merchandises do |t|
9       t.column :title, :string, :null => false
10       t.column :quantity, :integer, :null => false, :default => 0
11       t.column :price, :decimal, :precision => 8, :scale =>2, :default => 0
12     end
13   end
14
15   def self.down
16     drop_table :merchandises
17
18     create_table :merchandises do |t|
19       t.column :name, :string, :null => false
20       t.column :quantity, :integer, :null => false, :default => 0
21       t.column :price, :decimal, :precision => 8, :scale =>2, :default => 0
22     end
23   end
24 end