Skip to content
Snippets Groups Projects
Commit c78c1e3f authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Separate add_concurrent_index migration from background migration

parent ad55e33b
No related branches found
No related tags found
No related merge requests found
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
Loading
Loading
@@ -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,
Loading
Loading
@@ -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
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