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:
Diffstat (limited to 'db/post_migrate/20230924134453_cleanup_uuid_type_migration_on_vulnerability_occurrences.rb')
-rw-r--r--db/post_migrate/20230924134453_cleanup_uuid_type_migration_on_vulnerability_occurrences.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/db/post_migrate/20230924134453_cleanup_uuid_type_migration_on_vulnerability_occurrences.rb b/db/post_migrate/20230924134453_cleanup_uuid_type_migration_on_vulnerability_occurrences.rb
new file mode 100644
index 00000000000..192fa854502
--- /dev/null
+++ b/db/post_migrate/20230924134453_cleanup_uuid_type_migration_on_vulnerability_occurrences.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+class CleanupUuidTypeMigrationOnVulnerabilityOccurrences < Gitlab::Database::Migration[2.1]
+ TABLE = :vulnerability_occurrences
+ TRIGGER_NAME = "trigger_1a857e8db6cd"
+ COLUMN_NAME = "uuid"
+ TEMP_COLUMN_NAME = "uuid_convert_string_to_uuid"
+
+ disable_ddl_transaction!
+
+ def up
+ # Unfortunately I can't use cleanup_concurrent_column_type_change
+ # because it's not working with disable_ddl_transaction!
+ # In addition, it doesn't perform cleanup correctly because the original
+ # trigger was created using UnidirectionalCopyTrigger so it fails to remove
+ # the actual trigger
+ # rubocop:disable Migration/WithLockRetriesDisallowedMethod
+ with_lock_retries do
+ check_trigger_permissions!(TABLE)
+ remove_rename_triggers(TABLE, TRIGGER_NAME)
+ remove_column(TABLE, COLUMN_NAME)
+
+ rename_column(TABLE, TEMP_COLUMN_NAME, COLUMN_NAME)
+ end
+ # rubocop:enable Migration/WithLockRetriesDisallowedMethod
+ end
+
+ def down
+ undo_cleanup_concurrent_column_type_change(
+ TABLE,
+ COLUMN_NAME,
+ :string,
+ limit: 36,
+ temp_column: TEMP_COLUMN_NAME
+ )
+ change_column_null(TABLE, COLUMN_NAME, true)
+ end
+end