Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/post_migrate/20180424151928_fill_file_store.rb (renamed from db/post_migrate/20180424151928_fill_file_store.rb.rb)0
-rw-r--r--lib/gitlab/background_migration/fill_file_store_job_artifact.rb4
-rw-r--r--lib/gitlab/background_migration/fill_file_store_lfs_object.rb4
-rw-r--r--lib/gitlab/background_migration/fill_file_store_upload.rb4
-rw-r--r--spec/migrations/fill_file_store_spec.rb43
5 files changed, 49 insertions, 6 deletions
diff --git a/db/post_migrate/20180424151928_fill_file_store.rb.rb b/db/post_migrate/20180424151928_fill_file_store.rb
index e950d78e1dd..e950d78e1dd 100644
--- a/db/post_migrate/20180424151928_fill_file_store.rb.rb
+++ b/db/post_migrate/20180424151928_fill_file_store.rb
diff --git a/lib/gitlab/background_migration/fill_file_store_job_artifact.rb b/lib/gitlab/background_migration/fill_file_store_job_artifact.rb
index dfd1e7191d2..508e0102911 100644
--- a/lib/gitlab/background_migration/fill_file_store_job_artifact.rb
+++ b/lib/gitlab/background_migration/fill_file_store_job_artifact.rb
@@ -10,8 +10,8 @@ module Gitlab
end
def perform(start_id, stop_id)
- FillFileStoreJobArtifact::JobArtifact
- .where('file_store = NULL')
+ Gitlab::BackgroundMigration::FillFileStoreJobArtifact::JobArtifact
+ .where('file_store is NULL')
.where(id: (start_id..stop_id))
.update_all(file_store: 1)
end
diff --git a/lib/gitlab/background_migration/fill_file_store_lfs_object.rb b/lib/gitlab/background_migration/fill_file_store_lfs_object.rb
index d423bcfba95..5cd926b8121 100644
--- a/lib/gitlab/background_migration/fill_file_store_lfs_object.rb
+++ b/lib/gitlab/background_migration/fill_file_store_lfs_object.rb
@@ -10,8 +10,8 @@ module Gitlab
end
def perform(start_id, stop_id)
- FillFileStoreLfsObject::LfsObject
- .where('file_store = NULL')
+ Gitlab::BackgroundMigration::FillFileStoreLfsObject::LfsObject
+ .where('file_store is NULL')
.where(id: (start_id..stop_id))
.update_all(file_store: 1)
end
diff --git a/lib/gitlab/background_migration/fill_file_store_upload.rb b/lib/gitlab/background_migration/fill_file_store_upload.rb
index 14f4c667ed8..203c3cea09f 100644
--- a/lib/gitlab/background_migration/fill_file_store_upload.rb
+++ b/lib/gitlab/background_migration/fill_file_store_upload.rb
@@ -11,8 +11,8 @@ module Gitlab
end
def perform(start_id, stop_id)
- FillFileStoreUpload::Upload
- .where('store = NULL')
+ Gitlab::BackgroundMigration::FillFileStoreUpload::Upload
+ .where('store is NULL')
.where(id: (start_id..stop_id))
.update_all(store: 1)
end
diff --git a/spec/migrations/fill_file_store_spec.rb b/spec/migrations/fill_file_store_spec.rb
new file mode 100644
index 00000000000..5ff7aa56ce2
--- /dev/null
+++ b/spec/migrations/fill_file_store_spec.rb
@@ -0,0 +1,43 @@
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20180424151928_fill_file_store')
+
+describe FillFileStore, :migration do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:builds) { table(:ci_builds) }
+ let(:job_artifacts) { table(:ci_job_artifacts) }
+ let(:lfs_objects) { table(:lfs_objects) }
+ let(:uploads) { table(:uploads) }
+
+ before do
+ namespaces.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
+ projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1', namespace_id: 123)
+ builds.create!(id: 1)
+
+ ##
+ # Create rows that have nullfied `file_store` column
+ job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: nil)
+ lfs_objects.create!(oid: 123, size: 10, file: 'file_name', file_store: nil)
+ uploads.create!(size: 10, path: 'path', uploader: 'uploader', mount_point: 'file_name', store: nil)
+ end
+
+ it 'correctly migrates nullified file_store/store column' do
+ expect(job_artifacts.where(file_store: nil).count).to eq(1)
+ expect(lfs_objects.where(file_store: nil).count).to eq(1)
+ expect(uploads.where(store: nil).count).to eq(1)
+
+ expect(job_artifacts.where(file_store: 1).count).to eq(0)
+ expect(lfs_objects.where(file_store: 1).count).to eq(0)
+ expect(uploads.where(store: 1).count).to eq(0)
+
+ migrate!
+
+ expect(job_artifacts.where(file_store: nil).count).to eq(0)
+ expect(lfs_objects.where(file_store: nil).count).to eq(0)
+ expect(uploads.where(store: nil).count).to eq(0)
+
+ expect(job_artifacts.where(file_store: 1).count).to eq(1)
+ expect(lfs_objects.where(file_store: 1).count).to eq(1)
+ expect(uploads.where(store: 1).count).to eq(1)
+ end
+end