summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-06-03 14:21:50 +0900
committerShinya Maeda <shinya@gitlab.com>2018-06-04 14:14:20 +0900
commit0d00d02e842a0c4b22d213e00143a08d97597000 (patch)
tree2d05a270fc7493be0afcd5374af0153624df0e6a /db
parentb626fcc045dda7ac25b1b7d01229589d8fd00521 (diff)
downloadgitlab-ce-0d00d02e842a0c4b22d213e00143a08d97597000.tar.gz
Directly refer application code from migration code
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20180529152628_archive_legacy_traces.rb19
1 files changed, 4 insertions, 15 deletions
diff --git a/db/post_migrate/20180529152628_archive_legacy_traces.rb b/db/post_migrate/20180529152628_archive_legacy_traces.rb
index 78ec1ab1a94..12f219f606c 100644
--- a/db/post_migrate/20180529152628_archive_legacy_traces.rb
+++ b/db/post_migrate/20180529152628_archive_legacy_traces.rb
@@ -2,7 +2,7 @@ class ArchiveLegacyTraces < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- BATCH_SIZE = 10_000
+ BATCH_SIZE = 5000
BACKGROUND_MIGRATION_CLASS = 'ArchiveLegacyTraces'
disable_ddl_transaction!
@@ -14,25 +14,14 @@ class ArchiveLegacyTraces < ActiveRecord::Migration
scope :finished, -> { where(status: [:success, :failed, :canceled]) }
- scope :without_new_traces, ->() do
- where('NOT EXISTS (?)',
- ::ArchiveLegacyTraces::JobArtifact.select(1).trace.where('ci_builds.id = ci_job_artifacts.job_id'))
+ scope :without_archived_trace, -> do
+ where('NOT EXISTS (SELECT 1 FROM ci_job_artifacts WHERE ci_builds.id = ci_job_artifacts.job_id AND ci_job_artifacts.file_type = 3)')
end
end
- class JobArtifact < ActiveRecord::Base
- self.table_name = 'ci_job_artifacts'
-
- enum file_type: {
- archive: 1,
- metadata: 2,
- trace: 3
- }
- end
-
def up
queue_background_migration_jobs_by_range_at_intervals(
- ::ArchiveLegacyTraces::Build.finished.without_new_traces,
+ ::ArchiveLegacyTraces::Build.finished.without_archived_trace,
BACKGROUND_MIGRATION_CLASS,
5.minutes,
batch_size: BATCH_SIZE)