Moved card stuff from users model to new card model

This commit is contained in:
2012-10-14 05:46:19 -07:00
parent ccd432a67d
commit 0254f9aa2c
27 changed files with 384 additions and 332 deletions

View File

@@ -0,0 +1,10 @@
class CreateCards < ActiveRecord::Migration
def change
create_table :cards do |t|
t.string :card_number
t.integer :card_permissions
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddUserIdToCards < ActiveRecord::Migration
def change
add_column :cards, :user_id, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddNameToCards < ActiveRecord::Migration
def change
add_column :cards, :name, :string
end
end

View File

@@ -0,0 +1,11 @@
class MoveCardDataToCards < ActiveRecord::Migration
def up
User.all.each do |u|
u.cards.create(:id => u.card_id, :name => u.name, :card_number => u.card_number, :card_permissions => u.card_permissions)
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@@ -0,0 +1,13 @@
class RemoveCardFromUsers < ActiveRecord::Migration
def up
remove_column :users, :card_id
remove_column :users, :card_number
remove_column :users, :card_permissions
end
def down
add_column :users, :card_id, :integer
add_column :users, :card_number, :string
add_column :users, :card_permissions, :integer
end
end