diff options
author | Andrey Kumanyaev <me@zzet.org> | 2013-04-03 06:05:00 +0400 |
---|---|---|
committer | Andrey Kumanyaev <me@zzet.org> | 2013-04-03 06:21:04 +0400 |
commit | 734d6fcdf00846364fa39fc374753b7ea2cef603 (patch) | |
tree | 6fe992f84eedd670b989e246a53a4cdf111776b0 /db/migrate/20130403003950_add_last_activity_column_into_project.rb | |
parent | 41bbbb6df0300579867c4654d8662b38fa9f0a58 (diff) |
Perfomance updating Project activity sort
Diffstat (limited to 'db/migrate/20130403003950_add_last_activity_column_into_project.rb')
-rw-r--r-- | db/migrate/20130403003950_add_last_activity_column_into_project.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/migrate/20130403003950_add_last_activity_column_into_project.rb b/db/migrate/20130403003950_add_last_activity_column_into_project.rb new file mode 100644 index 00000000000..ddb04843de1 --- /dev/null +++ b/db/migrate/20130403003950_add_last_activity_column_into_project.rb @@ -0,0 +1,15 @@ +class AddLastActivityColumnIntoProject < ActiveRecord::Migration + def up + add_column :projects, :last_activity_at, :datetime + add_index :projects, :last_activity_at + + Project.find_each do |project| + project.update_attribute(:last_activity_at, project.last_activity_date) + end + end + + def down + remove_index :projects, :last_activity_at + remove_column :projects, :last_activity_at + end +end |