Skip to content
Snippets Groups Projects
Commit 1bf2dacf authored by Felipe Artur's avatar Felipe Artur
Browse files

Populate merge requests head_pipeline_id

parent 24824cbb
No related branches found
No related tags found
2 merge requests!12073Add RC2 changes to 9-3-stable,!10064Preloads head pipeline for each merge request
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
Loading
Loading
@@ -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
Loading
Loading
@@ -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|
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment