summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2019-01-30 09:39:48 -0600
committerMayra Cabrera <mcabrera@gitlab.com>2019-02-04 11:43:35 -0600
commit8b5553daa43d48fdef42f0f2a3f700580dea770b (patch)
tree64143238d3b114b4545ca431cd193f0f04577535 /spec/migrations
parent6fe15fdc5205700f5c31cdd0a4ca2d420840911e (diff)
downloadgitlab-ce-8b5553daa43d48fdef42f0f2a3f700580dea770b.tar.gz
Use a single sql statement for ADO query
Since cluster_projects table does not have a lot of records, currently it has 11,638, it seems better to use a single sql statement to update all the records
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb b/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb
index 09013ee4bd0..c7fd27588a5 100644
--- a/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb
+++ b/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb
@@ -46,12 +46,14 @@ describe MigrateAutoDevOpsDomainToClusterDomain, :migration do
let(:domain) { 'example-domain.com' }
before do
- setup_cluster_projects_with_domain(quantity: 20, domain: nil)
+ setup_cluster_projects_with_domain(quantity: 25, domain: nil)
end
it 'should only update specific cluster projects' do
migrate!
+ expect(clusters_with_domain.count).to eq(20)
+
project_auto_devops_with_domain.each do |project_auto_devops|
cluster_project = Clusters::Project.find_by(project_id: project_auto_devops.project_id)
cluster = Clusters::Cluster.find(cluster_project.cluster_id)
@@ -59,6 +61,8 @@ describe MigrateAutoDevOpsDomainToClusterDomain, :migration do
expect(cluster.domain).to be_present
end
+ expect(clusters_without_domain.count).to eq(25)
+
project_auto_devops_without_domain.each do |project_auto_devops|
cluster_project = Clusters::Project.find_by(project_id: project_auto_devops.project_id)
cluster = Clusters::Cluster.find(cluster_project.cluster_id)
@@ -74,10 +78,12 @@ describe MigrateAutoDevOpsDomainToClusterDomain, :migration do
cluster_projects = cluster_projects_table.last(quantity)
cluster_projects.each do |cluster_project|
+ specific_domain = "#{cluster_project.id}-#{domain}" if domain
+
project_auto_devops_table.create(
project_id: cluster_project.project_id,
enabled: true,
- domain: domain
+ domain: specific_domain
)
end
end