Commit fc8221ce authored by Grzegorz Bizon's avatar Grzegorz Bizon

Reduce scope of orphaned builds to be removed

parent 8624a4ed
......@@ -13,7 +13,7 @@ class AddPipelineBuildForeignKey < ActiveRecord::Migration
execute <<~SQL
DELETE FROM ci_builds WHERE NOT EXISTS
(SELECT true FROM ci_pipelines WHERE ci_pipelines.id = ci_builds.commit_id)
AND commit_id IS NOT NULL
AND stage_id IS NULL
SQL
add_concurrent_foreign_key(:ci_builds, :ci_pipelines, column: :commit_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment