diff --git a/db/migrate/20240206210111_increase_sbom_occurrence_input_file_name_limit.rb b/db/migrate/20240206210111_increase_sbom_occurrence_input_file_name_limit.rb new file mode 100644 index 0000000000000000000000000000000000000000..83eb0bf1ff9f7b36b98d4f484cd511e05c20627f --- /dev/null +++ b/db/migrate/20240206210111_increase_sbom_occurrence_input_file_name_limit.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class IncreaseSbomOccurrenceInputFileNameLimit < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.9' + + def up + add_text_limit(:sbom_occurrences, :input_file_path, 1024, + constraint_name: check_constraint_name(:sbom_occurrences, :input_file_path, 'max_length_1KiB')) + remove_text_limit :sbom_occurrences, :input_file_path, + constraint_name: check_constraint_name(:sbom_occurrences, :input_file_path, 'max_length') + end + + def down + # no-op: Danger of failing if there are records with length(input_file_path) > 255 + end +end diff --git a/db/schema_migrations/20240206210111 b/db/schema_migrations/20240206210111 new file mode 100644 index 0000000000000000000000000000000000000000..f7492bdb773ffb8b70d8bb6adbc31ef0aab22c1e --- /dev/null +++ b/db/schema_migrations/20240206210111 @@ -0,0 +1 @@ +86e7dc8cce7fee1b9b4a2492bcb7db181c480d347b8490120e2d5337da90daa6 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index c3e70f72ddfcf61e7491c006bb27075f5adfe775..5f4af450b8fe3623625ea1590ba5baf7469d6e20 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23655,7 +23655,7 @@ CREATE TABLE sbom_occurrences ( traversal_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL, CONSTRAINT check_3f2d2c7ffc CHECK ((char_length(package_manager) <= 255)), CONSTRAINT check_9b29021fa8 CHECK ((char_length(component_name) <= 255)), - CONSTRAINT check_bd1367d4c1 CHECK ((char_length(input_file_path) <= 255)) + CONSTRAINT check_e6b8437cfe CHECK ((char_length(input_file_path) <= 1024)) ); CREATE SEQUENCE sbom_occurrences_id_seq diff --git a/ee/app/models/sbom/occurrence.rb b/ee/app/models/sbom/occurrence.rb index bea7ebc57aa011bccb0f388b0bc83bc0506cc664..42d463e9b51e15cf8b729f9d00428b6b6ccf1c45 100644 --- a/ee/app/models/sbom/occurrence.rb +++ b/ee/app/models/sbom/occurrence.rb @@ -29,7 +29,7 @@ class Occurrence < ApplicationRecord validates :uuid, presence: true, uniqueness: { case_sensitive: false } validates :package_manager, length: { maximum: 255 } validates :component_name, length: { maximum: 255 } - validates :input_file_path, length: { maximum: 255 } + validates :input_file_path, length: { maximum: 1024 } validates :licenses, json_schema: { filename: 'sbom_occurrences-licenses' } delegate :name, to: :component diff --git a/ee/spec/models/sbom/occurrence_spec.rb b/ee/spec/models/sbom/occurrence_spec.rb index 27499eb5c0e70c70679fa863a61246d107821b9d..d0fa248ea47810ead59aeece97c4d3385c8524c2 100644 --- a/ee/spec/models/sbom/occurrence_spec.rb +++ b/ee/spec/models/sbom/occurrence_spec.rb @@ -31,7 +31,7 @@ it { is_expected.to validate_uniqueness_of(:uuid).case_insensitive } it { is_expected.to validate_length_of(:package_manager).is_at_most(255) } it { is_expected.to validate_length_of(:component_name).is_at_most(255) } - it { is_expected.to validate_length_of(:input_file_path).is_at_most(255) } + it { is_expected.to validate_length_of(:input_file_path).is_at_most(1024) } describe '#licenses' do subject { build(:sbom_occurrence, licenses: licenses) }