summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-09 20:58:47 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-09 20:58:47 +0300
commit4496a747c669611e35d758c994ed7ee9a235985a (patch)
tree87ba6bc84d22cb409cc77f7409d6cadb8f6c3b6b /db
parentae2233b1149392d63c6fa4ede8a58b7d82d7790c (diff)
downloadgitlab-ce-4496a747c669611e35d758c994ed7ee9a235985a.tar.gz
Improve migration AddLastActivityColumnIntoProject to use real last activity date if present
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20130403003950_add_last_activity_column_into_project.rb8
1 files changed, 7 insertions, 1 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
index ddb04843de1..2a036bd9993 100644
--- a/db/migrate/20130403003950_add_last_activity_column_into_project.rb
+++ b/db/migrate/20130403003950_add_last_activity_column_into_project.rb
@@ -4,7 +4,13 @@ class AddLastActivityColumnIntoProject < ActiveRecord::Migration
add_index :projects, :last_activity_at
Project.find_each do |project|
- project.update_attribute(:last_activity_at, project.last_activity_date)
+ last_activity_date = if project.last_activity
+ project.last_activity.created_at
+ else
+ project.updated_at
+ end
+
+ project.update_attribute(:last_activity_at, last_activity_date)
end
end