Skip to content

Project Topic: Add avatar and description to the model

Jonas Wälter requested to merge siemens/gitlab:topics-avatar-description into master

What does this MR do and why?

In the course of Issues #340920 (closed), we want to give a boost to the project topics 🚀

Up to now, a topic consists only of the name. In order to make the project topics better known, the topics should be enriched with a picture and a description. As a first step, this MR extends the Projects::Topic model with an avatar and a description.

  • The avatar property will be used in the same way as for users, projects, groups, ...
  • The description property will contain markdown text.

This MR is deliberately kept small and only includes the database migration. In further steps the topic avatar and description will be made maintainable for administrators and visible for users (see open tasks in #340920 (closed)).

🛠 with at Siemens

/cc @bufferoverflow

Database Migration

➜  rails db:migrate:up VERSION=20210915070423
== 20210915070423 AddAvatarAndDescriptionToTopic: migrating ===================
-- add_column(:topics, :avatar, :text)
   -> 0.0072s
-- add_column(:topics, :description, :text)
   -> 0.0051s
== 20210915070423 AddAvatarAndDescriptionToTopic: migrated (0.0126s) ==========
➜  rails db:migrate:down VERSION=20210915070423
== 20210915070423 AddAvatarAndDescriptionToTopic: reverting ===================
-- remove_column(:topics, :avatar)
   -> 0.0042s
-- remove_column(:topics, :description)
   -> 0.0021s
== 20210915070423 AddAvatarAndDescriptionToTopic: reverted (0.0067s) ==========
➜  rails db:migrate:up VERSION=20210920104446
== 20210920104446 AddTextLimitToTopicsDescriptionAndAvatar: migrating =========
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0006s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE topics\nADD CONSTRAINT check_5d1a07c8c8\nCHECK ( char_length(description) <= 1024 )\nNOT VALID;\n")
   -> 0.0058s
-- current_schema()
   -> 0.0003s
-- execute("SET statement_timeout TO 0")
   -> 0.0011s
-- execute("ALTER TABLE topics VALIDATE CONSTRAINT check_5d1a07c8c8;")
   -> 0.0052s
-- execute("RESET statement_timeout")
   -> 0.0012s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0005s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE topics\nADD CONSTRAINT check_26753fb43a\nCHECK ( char_length(avatar) <= 255 )\nNOT VALID;\n")
   -> 0.0029s
-- current_schema()
   -> 0.0012s
-- execute("ALTER TABLE topics VALIDATE CONSTRAINT check_26753fb43a;")
   -> 0.0045s
== 20210920104446 AddTextLimitToTopicsDescriptionAndAvatar: migrated (0.0712s)
➜  rails db:migrate:down VERSION=20210920104446
== 20210920104446 AddTextLimitToTopicsDescriptionAndAvatar: reverting =========
-- transaction_open?()
   -> 0.0000s
-- transaction_open?()
   -> 0.0001s
-- execute("ALTER TABLE topics\nDROP CONSTRAINT IF EXISTS check_26753fb43a\n")
   -> 0.0036s
-- transaction_open?()
   -> 0.0000s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE topics\nDROP CONSTRAINT IF EXISTS check_5d1a07c8c8\n")
   -> 0.0019s
== 20210920104446 AddTextLimitToTopicsDescriptionAndAvatar: reverted (0.0394s)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jonas Wälter

Merge request reports