summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-07-06 04:41:08 -0600
committermo khan <mo@mokhan.ca>2013-07-06 04:41:08 -0600
commit5de9ec968d4b6fde4fa597e1ea463e91c6bcafee (patch)
treec66fb41658892e1c088a7b601db606202d62fb1d /db/migrate
parent64fc4ee7a8da9742c04ba189f05737a6d6075d7c (diff)
add creations counter_cache
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20130706103848_add_creations_count_to_users.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/db/migrate/20130706103848_add_creations_count_to_users.rb b/db/migrate/20130706103848_add_creations_count_to_users.rb
new file mode 100644
index 00000000..e7f7b048
--- /dev/null
+++ b/db/migrate/20130706103848_add_creations_count_to_users.rb
@@ -0,0 +1,13 @@
+class AddCreationsCountToUsers < ActiveRecord::Migration
+ def up
+ add_column :users, :creations_count, :integer, :default => 0
+ User.reset_column_information
+ User.find_each do |user|
+ User.reset_counters user.id, :creations
+ end
+ end
+
+ def down
+ remove_column :users, :creations_count
+ end
+end