diff options
Diffstat (limited to 'db/migrate/20201021105959_add_check_constraint_to_segment_selection.rb')
-rw-r--r-- | db/migrate/20201021105959_add_check_constraint_to_segment_selection.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20201021105959_add_check_constraint_to_segment_selection.rb b/db/migrate/20201021105959_add_check_constraint_to_segment_selection.rb new file mode 100644 index 00000000000..68fec36aa8a --- /dev/null +++ b/db/migrate/20201021105959_add_check_constraint_to_segment_selection.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddCheckConstraintToSegmentSelection < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + CONSTRAINT_NAME = 'segment_selection_project_id_or_group_id_required' + + def up + add_check_constraint :analytics_devops_adoption_segment_selections, '(project_id != NULL AND group_id IS NULL) OR (group_id != NULL AND project_id IS NULL)', CONSTRAINT_NAME + end + + def down + remove_check_constraint :analytics_devops_adoption_segment_selections, CONSTRAINT_NAME + end +end |