summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2017-03-27 19:19:28 -0300
committerFelipe Artur <felipefac@gmail.com>2017-05-08 11:27:29 -0300
commit1bf2dacf2002fabf3b7bd364031d9020e5d0b624 (patch)
tree532fadb9aa10de269f4fa1aa66518d94ca7636b0 /db
parent24824cbb4c6d2c5ebd08dea03007f65c5df763da (diff)
downloadgitlab-ce-1bf2dacf2002fabf3b7bd364031d9020e5d0b624.tar.gz
Populate merge requests head_pipeline_id
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20170428170547_add_head_pipeline_for_each_merge_request.rb23
-rw-r--r--db/schema.rb2
2 files changed, 24 insertions, 1 deletions
diff --git a/db/post_migrate/20170428170547_add_head_pipeline_for_each_merge_request.rb b/db/post_migrate/20170428170547_add_head_pipeline_for_each_merge_request.rb
new file mode 100644
index 00000000000..0e139c28402
--- /dev/null
+++ b/db/post_migrate/20170428170547_add_head_pipeline_for_each_merge_request.rb
@@ -0,0 +1,23 @@
+class AddHeadPipelineForEachMergeRequest < ActiveRecord::Migration
+ DOWNTIME = false
+
+ class Pipeline < ActiveRecord::Base
+ self.table_name = "ci_pipelines"
+
+ def self.last_per_branch
+ select('ref, MAX(id) as head_id, project_id').group(:ref).group(:project_id)
+ end
+ end
+
+ class MergeRequest < ActiveRecord::Base; end
+
+ def up
+ Pipeline.last_per_branch.each do |pipeline|
+ mrs = MergeRequest.where(source_branch: pipeline.ref, source_project_id: pipeline.project_id)
+ mrs.update_all(head_pipeline_id: pipeline.head_id)
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d5b1d3bb0d8..d0e10f00ffd 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -114,6 +114,7 @@ ActiveRecord::Schema.define(version: 20170506185517) do
t.string "plantuml_url"
t.boolean "plantuml_enabled"
t.integer "terminal_max_session_time", default: 0, null: false
+ t.string "default_artifacts_expire_in", default: "0", null: false
t.integer "unique_ips_limit_per_user"
t.integer "unique_ips_limit_time_window"
t.boolean "unique_ips_limit_enabled", default: false, null: false
@@ -123,7 +124,6 @@ ActiveRecord::Schema.define(version: 20170506185517) do
t.integer "cached_markdown_version"
t.boolean "clientside_sentry_enabled", default: false, null: false
t.string "clientside_sentry_dsn"
- t.string "default_artifacts_expire_in", default: "0", null: false
end
create_table "audit_events", force: :cascade do |t|