Sha256: 9fc20cd4bee2895c84c33e3c5eb21a9f4a22d62c93c02a3d82694e1731ce0264
Contents?: true
Size: 700 Bytes
Versions: 24
Compression:
Stored size: 700 Bytes
Contents
class AddCacheCounters < ActiveRecord::Migration def self.up add_column :pageflow_accounts, :users_count, :integer, default: 0, null: false add_column :pageflow_accounts, :entries_count, :integer, default: 0, null: false execute(<<-SQL) UPDATE pageflow_accounts SET users_count = ( SELECT COUNT(*) FROM users WHERE users.account_id = pageflow_accounts.id ), entries_count = ( SELECT COUNT(*) FROM pageflow_entries WHERE pageflow_entries.account_id = pageflow_accounts.id ); SQL end def self.down remove_column :pageflow_accounts, :users_count remove_column :pageflow_accounts, :entries_count end end
Version data entries
24 entries across 24 versions & 1 rubygems