diff options
author | Marco Wessel <marco@poop.nl> | 2015-02-23 04:31:12 +0300 |
---|---|---|
committer | Marco Wessel <marco@poop.nl> | 2015-02-23 05:36:21 +0300 |
commit | b19b8c679a136234094443e2d4a345f136a0bcc1 (patch) | |
tree | b4f52165e12f2bba47d7860c66429c90dfa507ca | |
parent | ebe0d34128c31bb88f6eb5aca96fae012c7fcf8b (diff) |
Give last_activity_at a default value so it will always be set
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/project.rb | 6 | ||||
-rw-r--r-- | db/migrate/20150223022001_set_missing_last_activity_at.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 4 |
4 files changed, 18 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 6702ba2ba46..5bdcc535409 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ v 7.9.0 (unreleased) - Upgrade Rails gem to version 4.1.9. - Improve UI for commits, issues and merge request lists - Fix commit comments on first line of diff not rendering in Merge Request Discussion view. + - Fix ordering of imported but unchanged projects (Marco Wessel) v 7.8.0 - Fix access control and protection against XSS for note attachments and other uploads. diff --git a/app/models/project.rb b/app/models/project.rb index 91ab788083d..04189839d6d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -48,6 +48,12 @@ class Project < ActiveRecord::Base default_value_for :wall_enabled, false default_value_for :snippets_enabled, gitlab_config_features.snippets + # set last_activity_at to the same as updated_at + before_create :set_last_activity_at + def set_last_activity_at + self.last_activity_at = self.updated_at + end + ActsAsTaggableOn.strict_case_match = true acts_as_taggable_on :tags diff --git a/db/migrate/20150223022001_set_missing_last_activity_at.rb b/db/migrate/20150223022001_set_missing_last_activity_at.rb new file mode 100644 index 00000000000..3a3adf18872 --- /dev/null +++ b/db/migrate/20150223022001_set_missing_last_activity_at.rb @@ -0,0 +1,9 @@ +class SetMissingLastActivityAt < ActiveRecord::Migration + def up + execute "UPDATE projects SET last_activity_at = updated_at WHERE last_activity_at IS NULL" + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/schema.rb b/db/schema.rb index e11a068c9c5..d34eab75085 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150213121042) do +ActiveRecord::Schema.define(version: 20150223022001) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -334,12 +334,12 @@ ActiveRecord::Schema.define(version: 20150213121042) do t.string "import_url" t.integer "visibility_level", default: 0, null: false t.boolean "archived", default: false, null: false - t.string "avatar" t.string "import_status" t.float "repository_size", default: 0.0 t.integer "star_count", default: 0, null: false t.string "import_type" t.string "import_source" + t.string "avatar" end add_index "projects", ["created_at", "id"], name: "index_projects_on_created_at_and_id", using: :btree |