summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMrYummy <elemental428@gmail.com>2017-06-02 19:34:06 +0200
committerMrYummy <elemental428@gmail.com>2017-06-18 13:11:36 -0400
commit617890c2097c554b69382ecfec5cc9a7f016fddd (patch)
tree0a8577a9f82464cb76867e41d2405abf556ccca4
parent79ad8b201edeecfa8c3402b302fa43af0c802328 (diff)
badge migration now contains default badges and creation of badge table
-rw-r--r--db/migrate/20170319193517_add_badge_id_to_users.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/db/migrate/20170319193517_add_badge_id_to_users.rb b/db/migrate/20170319193517_add_badge_id_to_users.rb
index 08328cf..4e9d7ed 100644
--- a/db/migrate/20170319193517_add_badge_id_to_users.rb
+++ b/db/migrate/20170319193517_add_badge_id_to_users.rb
@@ -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