提交 c78c1e3f 编写于 作者: S Shinya Maeda

Separate add_concurrent_index migration from background migration

上级 ad55e33b
class AddIndexToCiBuildsArtifactsFile < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# We add an temporary index to `ci_builds.artifacts_file` column to avoid statements timeout in legacy artifacts migrations
# This index is to be removed after we have cleaned up background migrations
# https://gitlab.com/gitlab-org/gitlab-ce/issues/46866
add_concurrent_index :ci_builds, :artifacts_file, where: "artifacts_file <> ''"
end
def down
remove_concurrent_index :ci_builds, :artifacts_file, where: "artifacts_file <> ''"
end
end
......@@ -30,13 +30,6 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration
end
def up
# We add an temporary index to `ci_builds.artifacts_file` column to avoid statements timeout
# This index is to be removed after we have cleaned up background migrations
# https://gitlab.com/gitlab-org/gitlab-ce/issues/46866
unless index_exists?(:ci_builds, :artifacts_file)
add_concurrent_index :ci_builds, :artifacts_file, where: "artifacts_file <> ''"
end
MigrateLegacyArtifactsToJobArtifacts::Build.legacy_artifacts.without_new_artifacts.tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
MIGRATION,
......@@ -46,8 +39,6 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration
end
def down
if index_exists?(:ci_builds, :artifacts_file)
remove_concurrent_index :ci_builds, :artifacts_file, where: "artifacts_file <> ''"
end
# no-op
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册