diff options
author | Robert Speicher <robert@gitlab.com> | 2015-08-24 22:11:29 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2015-08-24 22:11:29 +0000 |
commit | af8aed8c27bbb7831dbf640553dce580b57f5b4c (patch) | |
tree | db368e4e3bf7da69ba046ee23057d079c5eefac9 | |
parent | b09e00e14f6f0f17d6b9dcc9417354fdb165049c (diff) | |
parent | 349764beee84d45da26703fd07f325815beb8c7f (diff) | |
download | gitlab-ci-af8aed8c27bbb7831dbf640553dce580b57f5b4c.tar.gz |
Merge branch 'ordering-issue' into 'master'
Order commits by committed_at and id
This needs to be done that way, because the committed_at can be null for some pretty old commits.
This is needed to resolve the issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/2339
See merge request !240
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | db/migrate/20150824202238_add_index_for_committed_at_and_id.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 3 |
4 files changed, 9 insertions, 2 deletions
@@ -1,5 +1,6 @@ v7.14.1 - Fix skipped svg + - Fix commits ordering v7.14.0 - Truncate commit messages after subject line in table diff --git a/app/models/project.rb b/app/models/project.rb index 4879f24..f0cf3a5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -28,7 +28,7 @@ class Project < ActiveRecord::Base include ProjectStatus - has_many :commits, ->() { order(:committed_at) }, dependent: :destroy + has_many :commits, ->() { order(:committed_at, :id) }, dependent: :destroy has_many :builds, through: :commits, dependent: :destroy has_many :runner_projects, dependent: :destroy has_many :runners, through: :runner_projects diff --git a/db/migrate/20150824202238_add_index_for_committed_at_and_id.rb b/db/migrate/20150824202238_add_index_for_committed_at_and_id.rb new file mode 100644 index 0000000..3328b9b --- /dev/null +++ b/db/migrate/20150824202238_add_index_for_committed_at_and_id.rb @@ -0,0 +1,5 @@ +class AddIndexForCommittedAtAndId < ActiveRecord::Migration + def up + add_index :commits, [:project_id, :committed_at, :id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f630ab..db684af 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: 20150819162227) do +ActiveRecord::Schema.define(version: 20150824202238) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -62,6 +62,7 @@ ActiveRecord::Schema.define(version: 20150819162227) do t.datetime "committed_at" end + add_index "commits", ["project_id", "committed_at", "id"], name: "index_commits_on_project_id_and_committed_at_and_id", using: :btree add_index "commits", ["project_id", "committed_at"], name: "index_commits_on_project_id_and_committed_at", using: :btree add_index "commits", ["project_id", "sha"], name: "index_commits_on_project_id_and_sha", using: :btree add_index "commits", ["project_id"], name: "index_commits_on_project_id", using: :btree |