diff --git a/app/models/project/life_cycle_step_definition.rb b/app/models/project/life_cycle_step_definition.rb index c420e696dbd5..391bc1cd0733 100644 --- a/app/models/project/life_cycle_step_definition.rb +++ b/app/models/project/life_cycle_step_definition.rb @@ -37,7 +37,7 @@ class Project::LifeCycleStepDefinition < ApplicationRecord has_many :projects, through: :life_cycle_steps belongs_to :color, optional: false - validates :name, presence: true + validates :name, presence: true, uniqueness: true validates :type, inclusion: { in: %w[Project::StageDefinition Project::GateDefinition], message: :must_be_a_stage_or_gate } attr_readonly :type diff --git a/db/migrate/20241217190533_add_uniqueness_index_to_project_life_cycle_step_definitions_name.rb b/db/migrate/20241217190533_add_uniqueness_index_to_project_life_cycle_step_definitions_name.rb new file mode 100644 index 000000000000..f6aba362e529 --- /dev/null +++ b/db/migrate/20241217190533_add_uniqueness_index_to_project_life_cycle_step_definitions_name.rb @@ -0,0 +1,5 @@ +class AddUniquenessIndexToProjectLifeCycleStepDefinitionsName < ActiveRecord::Migration[7.1] + def change + add_index :project_life_cycle_step_definitions, :name, unique: true + end +end