Commit c73795c6 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch '322745-validate-null-constraint' into 'master'

Validate null constraint for token name

See merge request gitlab-org/gitlab!56868
parents 10b8d3d3 299bc0b8
......@@ -19,7 +19,7 @@ module Clusters
before_save :ensure_token
validates :description, length: { maximum: 1024 }
validates :name, presence: true, length: { maximum: 255 }, on: :create
validates :name, presence: true, length: { maximum: 255 }
def track_usage
track_values = { last_used_at: Time.current.utc }
......
---
title: Validate null constraint for cluster token name
merge_request: 56868
author:
type: changed
# frozen_string_literal: true
class ValidateNotNullConstraintOnClusterTokenName < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
validate_not_null_constraint :cluster_agent_tokens, :name
end
def down
# no-op
end
end
b6c30723c2be7dd0afe535272cded230db4954bfe914d5087542be2c27d0ad79
\ No newline at end of file
......@@ -11199,6 +11199,7 @@ CREATE TABLE cluster_agent_tokens (
description text,
name text,
last_used_at timestamp with time zone,
CONSTRAINT check_0fb634d04d CHECK ((name IS NOT NULL)),
CONSTRAINT check_2b79dbb315 CHECK ((char_length(name) <= 255)),
CONSTRAINT check_4e4ec5070a CHECK ((char_length(description) <= 1024)),
CONSTRAINT check_c60daed227 CHECK ((char_length(token_encrypted) <= 255))
......@@ -20233,9 +20234,6 @@ ALTER TABLE ONLY chat_names
ALTER TABLE ONLY chat_teams
ADD CONSTRAINT chat_teams_pkey PRIMARY KEY (id);
ALTER TABLE cluster_agent_tokens
ADD CONSTRAINT check_0fb634d04d CHECK ((name IS NOT NULL)) NOT VALID;
ALTER TABLE vulnerability_scanners
ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) NOT VALID;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment