diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /db/post_migrate/20210525075724_clean_up_pending_builds_table.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'db/post_migrate/20210525075724_clean_up_pending_builds_table.rb')
-rw-r--r-- | db/post_migrate/20210525075724_clean_up_pending_builds_table.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/db/post_migrate/20210525075724_clean_up_pending_builds_table.rb b/db/post_migrate/20210525075724_clean_up_pending_builds_table.rb new file mode 100644 index 00000000000..c380f15188a --- /dev/null +++ b/db/post_migrate/20210525075724_clean_up_pending_builds_table.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class CleanUpPendingBuildsTable < ActiveRecord::Migration[6.0] + include ::Gitlab::Database::DynamicModelHelpers + + BATCH_SIZE = 1000 + + disable_ddl_transaction! + + def up + return unless Gitlab.dev_or_test_env? || Gitlab.com? + + each_batch_range('ci_pending_builds', of: BATCH_SIZE) do |min, max| + execute <<~SQL + DELETE FROM ci_pending_builds + USING ci_builds + WHERE ci_builds.id = ci_pending_builds.build_id + AND ci_builds.status != 'pending' + AND ci_builds.type = 'Ci::Build' + AND ci_pending_builds.id BETWEEN #{min} AND #{max} + SQL + end + end + + def down + # noop + end +end |