blob: 192fa8545021c9395ae31db13883dd7abe5e3ad4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
|