Moved card stuff from users model to new card model
This commit is contained in:
10
db/migrate/20121014114058_create_cards.rb
Normal file
10
db/migrate/20121014114058_create_cards.rb
Normal 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
|
||||
5
db/migrate/20121014114527_add_user_id_to_cards.rb
Normal file
5
db/migrate/20121014114527_add_user_id_to_cards.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddUserIdToCards < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :cards, :user_id, :integer
|
||||
end
|
||||
end
|
||||
5
db/migrate/20121014120140_add_name_to_cards.rb
Normal file
5
db/migrate/20121014120140_add_name_to_cards.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddNameToCards < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :cards, :name, :string
|
||||
end
|
||||
end
|
||||
11
db/migrate/20121014120609_move_card_data_to_cards.rb
Normal file
11
db/migrate/20121014120609_move_card_data_to_cards.rb
Normal 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
|
||||
13
db/migrate/20121014122548_remove_card_from_users.rb
Normal file
13
db/migrate/20121014122548_remove_card_from_users.rb
Normal 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
|
||||
Reference in New Issue
Block a user