diff options
Diffstat (limited to 'db/post_migrate/20211209203821_convert_stringified_raw_metadata_hash_to_json.rb')
-rw-r--r-- | db/post_migrate/20211209203821_convert_stringified_raw_metadata_hash_to_json.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/db/post_migrate/20211209203821_convert_stringified_raw_metadata_hash_to_json.rb b/db/post_migrate/20211209203821_convert_stringified_raw_metadata_hash_to_json.rb new file mode 100644 index 00000000000..757cbf60d4d --- /dev/null +++ b/db/post_migrate/20211209203821_convert_stringified_raw_metadata_hash_to_json.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true +class ConvertStringifiedRawMetadataHashToJson < Gitlab::Database::Migration[1.0] + MIGRATION_CLASS = Gitlab::BackgroundMigration::FixVulnerabilityOccurrencesWithHashesAsRawMetadata + MODEL_CLASS = MIGRATION_CLASS::Finding + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 500 + + disable_ddl_transaction! + + def up + queue_background_migration_jobs_by_range_at_intervals( + MODEL_CLASS.by_api_report_types, + MIGRATION_CLASS, + DELAY_INTERVAL, + batch_size: BATCH_SIZE + ) + end + + def down + # no-op + + # up fixes invalid data by updating columns in-place. + # It is a backwards-compatible change, and reversing it in a downgrade would not be desirable. + end +end |