diff --git a/db/migrate/20180428200509_add_index_to_ci_builds_artifacts_file.rb b/db/migrate/20180428200509_add_index_to_ci_builds_artifacts_file.rb new file mode 100644 index 0000000000000000000000000000000000000000..d2bfb1f938ba4f6a324d6cc7d62dd26ec467de8e --- /dev/null +++ b/db/migrate/20180428200509_add_index_to_ci_builds_artifacts_file.rb @@ -0,0 +1,18 @@ +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 diff --git a/db/post_migrate/20180427161409_migrate_legacy_artifacts_to_job_artifacts.rb b/db/post_migrate/20180430161409_migrate_legacy_artifacts_to_job_artifacts.rb similarity index 70% rename from db/post_migrate/20180427161409_migrate_legacy_artifacts_to_job_artifacts.rb rename to db/post_migrate/20180430161409_migrate_legacy_artifacts_to_job_artifacts.rb index 4a3d4e1b38de3b4e19130c38b061a4cc791d4f94..5f0076c10efcd43a589770c158fb136b34fa93b1 100644 --- a/db/post_migrate/20180427161409_migrate_legacy_artifacts_to_job_artifacts.rb +++ b/db/post_migrate/20180430161409_migrate_legacy_artifacts_to_job_artifacts.rb @@ -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