Commit 31d4b47d authored by Sean Arnold's avatar Sean Arnold

Add url_text column to issuable metric images

Changelog: added
parent 68755b38
# frozen_string_literal: true
class AddUrlTextToIssuableMetricImages < Gitlab::Database::Migration[1.0]
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20220118020026_add_url_text_limit_to_issuable_metric_images
def change
add_column :issuable_metric_images, :url_text, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
end
# frozen_string_literal: true
class AddUrlTextLimitToIssuableMetricImages < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_text_limit :issuable_metric_images, :url_text, 128
end
def down
remove_text_limit :issuable_metric_images, :url_text
end
end
6a73f49306de7c799a39afa3ac1f761840860833a96f1a91cf992c9a3ebfef9b
\ No newline at end of file
77374c81456f235d3afeb45cdda14552e1ef8047de5aaa3f5bb0a82e4aebe849
\ No newline at end of file
......@@ -15348,6 +15348,8 @@ CREATE TABLE issuable_metric_images (
file_store smallint,
file text NOT NULL,
url text,
url_text text,
CONSTRAINT check_3bc6d47661 CHECK ((char_length(url_text) <= 128)),
CONSTRAINT check_5b3011e234 CHECK ((char_length(url) <= 255)),
CONSTRAINT check_7ed527062f CHECK ((char_length(file) <= 255))
);
......@@ -15,6 +15,7 @@ class IssuableMetricImage < ApplicationRecord
validates :file, presence: true
validate :validate_file_is_image
validates :url, length: { maximum: 255 }, public_url: { allow_blank: true }
validates :url_text, length: { maximum: 128 }
scope :order_created_at_asc, -> { order(created_at: :asc) }
......
......@@ -15,6 +15,7 @@ RSpec.describe IssuableMetricImage do
it { is_expected.not_to allow_value(txt_file).for(:file) }
it { is_expected.to allow_value(img_file).for(:file) }
it { is_expected.to validate_length_of(:url_text).is_at_most(128) }
describe 'url' do
it { is_expected.not_to allow_value('test').for(:url) }
......
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