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
|
||||
14
db/schema.rb
14
db/schema.rb
@@ -10,7 +10,16 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120904024426) do
|
||||
ActiveRecord::Schema.define(:version => 20121014122548) do
|
||||
|
||||
create_table "cards", :force => true do |t|
|
||||
t.string "card_number"
|
||||
t.integer "card_permissions"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "user_id"
|
||||
t.string "name"
|
||||
end
|
||||
|
||||
create_table "door_logs", :force => true do |t|
|
||||
t.string "key"
|
||||
@@ -21,9 +30,6 @@ ActiveRecord::Schema.define(:version => 20120904024426) do
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "card_id"
|
||||
t.string "card_number"
|
||||
t.integer "card_permissions"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "email", :default => "", :null => false
|
||||
|
||||
Reference in New Issue
Block a user