badge migration now contains default badges and creation of badge table

This commit is contained in:
MrYummy
2017-06-02 19:34:06 +02:00
parent 79ad8b201e
commit 617890c209

View File

@@ -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