summaryrefslogtreecommitdiff
path: root/db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb')
-rw-r--r--db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb b/db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb
new file mode 100644
index 00000000000..2ab7f8a9c04
--- /dev/null
+++ b/db/post_migrate/20221025115006_check_vulnerabilities_state_transition_from_state_not_equal_to_state.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CheckVulnerabilitiesStateTransitionFromStateNotEqualToState < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_check_constraint(:vulnerability_state_transitions, '(from_state != to_state)', constraint_name)
+ end
+
+ def down
+ remove_check_constraint(:vulnerability_state_transitions, constraint_name)
+ end
+
+ private
+
+ def constraint_name
+ check_constraint_name('vulnerability_state_transitions', 'fully_qualified_table_name', 'state_not_equal')
+ end
+end