Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/data_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class DataType < ApplicationRecord
has_translation :display_messages, purpose: :display_message
has_translation :aliases, purpose: :alias

validates :identifier, presence: true, length: { maximum: 200 },
uniqueness: { case_sensitive: false, scope: :runtime_id }
validates :type, presence: true, length: { maximum: 65_536 }
validates :definition_source, length: { maximum: 50 }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class IncreaseDataTypeIdentifierLimit < Code0::ZeroTrack::Database::Migration[1.0]
def change
remove_check_constraint :data_types, 'char_length(identifier) <= 50', name: 'check_3a7198812e'

add_check_constraint :data_types, 'char_length(identifier) <= 200', name: 'check_3a7198812e'
end
end
1 change: 1 addition & 0 deletions db/schema_migrations/20260802173300
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dae616c0f9d3387cc26c3f3bd158c371757a26df88a597baf79b9e24dfbd8298
2 changes: 1 addition & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ CREATE TABLE data_types (
definition_source text,
runtime_module_id bigint NOT NULL,
CONSTRAINT check_01ca31b7b9 CHECK ((char_length(type) <= 65536)),
CONSTRAINT check_3a7198812e CHECK ((char_length(identifier) <= 50)),
CONSTRAINT check_3a7198812e CHECK ((char_length(identifier) <= 200)),
CONSTRAINT check_a133157a46 CHECK ((char_length(definition_source) <= 50))
);

Expand Down
3 changes: 3 additions & 0 deletions spec/models/data_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
end

describe 'validations' do
it { is_expected.to validate_presence_of(:identifier) }
it { is_expected.to validate_length_of(:identifier).is_at_most(200) }
it { is_expected.to validate_uniqueness_of(:identifier).case_insensitive.scoped_to(:runtime_id) }
it { is_expected.to validate_presence_of(:type) }
it { is_expected.to validate_length_of(:type).is_at_most(65_536) }
it { is_expected.to validate_length_of(:definition_source).is_at_most(50) }
Expand Down