Project topics: add title (model, management, API)
What does this MR do and why?
This MR is the 5. step of #351871 (closed).
As discussed in #351871 (comment 837067750), this MR adds a title
to the Projects::Topic
model (beside the already existing name
.).
-
Name: case insensitive unique slug of the topic used for the URL of the Topic detail page (
gitlab.com/explore/projects/topics/<slug>
).- Examples:
aws
,cli
,android
- Examples:
-
Title: title of topic to be shown on the Topic detail page later.
- Examples:
Amazon Web Services
,Command line interface
,Android
- Examples:
This MR extends the topic management (Admin area) and the Topic API to manage the topic title. In a follow-up MR, the topic title will also be shown on the Topic detail page instead of the name.
/cc @bufferoverflow
Screenshots
Add/edit topic (before) | Add/edit topic (after) |
---|---|
💾 Database review
⤴ Migration up
$ scripts/db_tasks db:migrate
== 20220331125725 AddTitleToTopic: migrating ==================================
-- add_column(:topics, :title, :text)
-> 0.0015s
== 20220331125725 AddTitleToTopic: migrated (0.0016s) =========================
== 20220331130726 AddTextLimitToTopicsTitle: migrating ========================
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0005s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE topics\nADD CONSTRAINT check_223b50f9be\nCHECK ( char_length(title) <= 255 )\nNOT VALID;\n")
-> 0.0009s
-- current_schema()
-> 0.0003s
-- execute("SET statement_timeout TO 0")
-> 0.0003s
-- execute("ALTER TABLE topics VALIDATE CONSTRAINT check_223b50f9be;")
-> 0.0005s
-- execute("RESET statement_timeout")
-> 0.0003s
== 20220331130726 AddTextLimitToTopicsTitle: migrated (0.0145s) ===============
== 20220331133802 ScheduleBackfillTopicsTitle: migrating ======================
-- Scheduled 0 BackfillTopicsTitle jobs with a maximum of 1000 records per batch and an interval of 120 seconds.
The migration is expected to take at least 0 seconds. Expect all jobs to have completed after 2022-04-06 13:31:27 UTC."
== 20220331133802 ScheduleBackfillTopicsTitle: migrated (0.0742s) =============
⤵ Migration down
$ scripts/db_tasks db:migrate:down VERSION=20220331133802
== 20220331133802 ScheduleBackfillTopicsTitle: reverting ======================
== 20220331133802 ScheduleBackfillTopicsTitle: reverted (0.0000s) =============
$ scripts/db_tasks db:migrate:down VERSION=20220331130726
== 20220331130726 AddTextLimitToTopicsTitle: reverting ========================
-- transaction_open?()
-> 0.0000s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE topics\nDROP CONSTRAINT IF EXISTS check_223b50f9be\n")
-> 0.0010s
== 20220331130726 AddTextLimitToTopicsTitle: reverted (0.0102s) ===============
$ scripts/db_tasks db:migrate:down VERSION=20220331125725
== 20220331125725 AddTitleToTopic: reverting ==================================
-- remove_column(:topics, :title, :text)
-> 0.0018s
== 20220331125725 AddTitleToTopic: reverted (0.0204s) =========================
How to set up and validate locally
- Sign in as administrator
- Visit
http://localhost:3000/admin/topics
- Add/edit topics
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Jonas Wälter