badge migration now contains default badges and creation of badge table
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
class AddBadgeIdToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :badge_id, :integer
|
||||
|
||||
create_table "badges", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "symbol"
|
||||
t.string "color"
|
||||
end
|
||||
|
||||
dbadge = Badge.create!({name: "donor", symbol: "$", color: "#f60"})
|
||||
|
||||
add_column :users, :badge_id, :integer, default: 0
|
||||
User.where(donor: true).update_all(badge_id: 1)
|
||||
User.where(donor: true).update_all(badge_id: dbadge.id)
|
||||
remove_column :users, :donor
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user