summaryrefslogtreecommitdiff
path: root/spec/migrations/20220503035221_add_gitlab_schema_to_batched_background_migrations_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 11:10:13 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 11:10:13 +0000
commit0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch)
tree7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/migrations/20220503035221_add_gitlab_schema_to_batched_background_migrations_spec.rb
parent72123183a20411a36d607d70b12d57c484394c8e (diff)
downloadgitlab-ce-0ea3fcec397b69815975647f5e2aa5fe944a8486.tar.gz
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/migrations/20220503035221_add_gitlab_schema_to_batched_background_migrations_spec.rb')
-rw-r--r--spec/migrations/20220503035221_add_gitlab_schema_to_batched_background_migrations_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/migrations/20220503035221_add_gitlab_schema_to_batched_background_migrations_spec.rb b/spec/migrations/20220503035221_add_gitlab_schema_to_batched_background_migrations_spec.rb
new file mode 100644
index 00000000000..5002c665c79
--- /dev/null
+++ b/spec/migrations/20220503035221_add_gitlab_schema_to_batched_background_migrations_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe AddGitlabSchemaToBatchedBackgroundMigrations do
+ it 'sets gitlab_schema for existing methods to "gitlab_main" and default to NULL' do
+ batched_migrations = table(:batched_background_migrations)
+ batched_migration = batched_migrations.create!(
+ id: 1, created_at: Time.now, updated_at: Time.now,
+ max_value: 100, batch_size: 100, sub_batch_size: 10, interval: 120,
+ job_class_name: 'TestJob', table_name: '_test', column_name: 'id'
+ )
+
+ reversible_migration do |migration|
+ migration.before -> {
+ batched_migrations.reset_column_information
+ column = batched_migrations.columns.find { |column| column.name == 'gitlab_schema' }
+
+ expect(column).to be_nil
+ }
+
+ migration.after -> {
+ expect(batched_migration.reload.gitlab_schema).to eq('gitlab_main')
+
+ batched_migrations.reset_column_information
+ column = batched_migrations.columns.find { |column| column.name == 'gitlab_schema' }
+
+ expect(column).to be
+ expect(column.default).to be_nil
+ }
+ end
+ end
+end