Skip to content

Commit

Permalink
add unique constraint for life cycle step definition name
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Dec 17, 2024
1 parent 9f4ad5d commit b63fae5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/project/life_cycle_step_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddUniquenessIndexToProjectLifeCycleStepDefinitionsName < ActiveRecord::Migration[7.1]
def change
add_index :project_life_cycle_step_definitions, :name, unique: true
end
end

0 comments on commit b63fae5

Please sign in to comment.