Commit 23bb155b authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'topics-avatar-description' into 'master'

Project Topic: Add avatar and description to the model

See merge request gitlab-org/gitlab!70386
parents 94fe7eb2 e45661a1
......@@ -2,7 +2,10 @@
module Projects
class Topic < ApplicationRecord
include Avatarable
validates :name, presence: true, uniqueness: true, length: { maximum: 255 }
validates :description, length: { maximum: 1024 }
has_many :project_topics, class_name: 'Projects::ProjectTopic'
has_many :projects, through: :project_topics
......
# frozen_string_literal: true
class AddAvatarAndDescriptionToTopic < Gitlab::Database::Migration[1.0]
# rubocop:disable Migration/AddLimitToTextColumns
def up
add_column :topics, :avatar, :text
add_column :topics, :description, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
def down
remove_column :topics, :avatar
remove_column :topics, :description
end
end
# frozen_string_literal: true
class AddTextLimitToTopicsDescriptionAndAvatar < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_text_limit :topics, :description, 1024
add_text_limit :topics, :avatar, 255
end
def down
remove_text_limit :topics, :avatar
remove_text_limit :topics, :description
end
end
f11b237fab6b4133c73f1d6105d85c8db1548b6d0753b2fd96f613c90a4fa3c1
\ No newline at end of file
e7e9b13874081a7df42d07ccc9a54fb81973210d1c175cd995300f6339d57495
\ No newline at end of file
......@@ -19593,6 +19593,10 @@ CREATE TABLE topics (
name text NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
avatar text,
description text,
CONSTRAINT check_26753fb43a CHECK ((char_length(avatar) <= 255)),
CONSTRAINT check_5d1a07c8c8 CHECK ((char_length(description) <= 1024)),
CONSTRAINT check_7a90d4c757 CHECK ((char_length(name) <= 255))
);
......@@ -18,5 +18,6 @@ RSpec.describe Projects::Topic do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_uniqueness_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_most(255) }
it { is_expected.to validate_length_of(:description).is_at_most(1024) }
end
end
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