summaryrefslogtreecommitdiff
path: root/app/models/terraform/state.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/terraform/state.rb')
-rw-r--r--app/models/terraform/state.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/terraform/state.rb b/app/models/terraform/state.rb
index efbbd86ae4a..eb7d465d585 100644
--- a/app/models/terraform/state.rb
+++ b/app/models/terraform/state.rb
@@ -22,7 +22,9 @@ module Terraform
scope :versioning_not_enabled, -> { where(versioning_enabled: false) }
scope :ordered_by_name, -> { order(:name) }
+ scope :with_name, -> (name) { where(name: name) }
+ validates :name, presence: true, uniqueness: { scope: :project_id }
validates :project_id, presence: true
validates :uuid, presence: true, uniqueness: true, length: { is: UUID_LENGTH },
format: { with: HEX_REGEXP, message: 'only allows hex characters' }