diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-13 19:27:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-13 19:27:03 +0000 |
commit | 7f5f940041c8d1ee074be96cc64bdccdd95649b1 (patch) | |
tree | 334342b5d7c1898efcbe345c51838b63aa5106bc /db | |
parent | b16db1458f5e0f6b0427cf3e2471302657297427 (diff) | |
download | gitlab-ce-7f5f940041c8d1ee074be96cc64bdccdd95649b1.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.4
Diffstat (limited to 'db')
3 files changed, 41 insertions, 2 deletions
diff --git a/db/post_migrate/20201005094331_migrate_compliance_framework_enum_to_database_framework_record.rb b/db/post_migrate/20201005094331_migrate_compliance_framework_enum_to_database_framework_record.rb index 5e261637d46..a5fab8576e4 100644 --- a/db/post_migrate/20201005094331_migrate_compliance_framework_enum_to_database_framework_record.rb +++ b/db/post_migrate/20201005094331_migrate_compliance_framework_enum_to_database_framework_record.rb @@ -52,8 +52,6 @@ class MigrateComplianceFrameworkEnumToDatabaseFrameworkRecord < ActiveRecord::Mi end def up - return unless Gitlab.ee? - TmpComplianceFramework.reset_column_information TmpProjectSettings.reset_column_information diff --git a/db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb b/db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb new file mode 100644 index 00000000000..08f92d21f44 --- /dev/null +++ b/db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class EnsureNamespaceSettingsCreation < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 10000 + MIGRATION = 'BackfillNamespaceSettings' + DELAY_INTERVAL = 2.minutes.to_i + + disable_ddl_transaction! + + class Namespace < ActiveRecord::Base + include EachBatch + + self.table_name = 'namespaces' + end + + def up + ensure_data_migration + end + + def down + # no-op + end + + private + + def ensure_data_migration + Namespace.each_batch(of: BATCH_SIZE) do |query, index| + missing_count = query.where("NOT EXISTS (SELECT 1 FROM namespace_settings WHERE namespace_settings.namespace_id=namespaces.id)").limit(1).size + + if missing_count > 0 + ids_range = query.pluck("MIN(id), MAX(id)").flatten + + migrate_in(index * DELAY_INTERVAL, MIGRATION, ids_range) + end + end + end +end diff --git a/db/schema_migrations/20201104124300 b/db/schema_migrations/20201104124300 new file mode 100644 index 00000000000..6c54da0da54 --- /dev/null +++ b/db/schema_migrations/20201104124300 @@ -0,0 +1 @@ +e17da7eebb6d054a711368369d2b4fa684e96344f845bb7c6b3c89a9b4c4e067
\ No newline at end of file |