Add url_text column to issuable metric images, and allow updates to url and url_text
What does this MR do and why?
This MR does two things:
- It adds
url_text
column toissuable_metric_images
, with a limit of128
chars - It adds an update API, for updating the
url
andurl_text
fields.
Migration
Up:
== 20220118015633 AddUrlTextToIssuableMetricImages: migrating =================
-- add_column(:issuable_metric_images, :url_text, :text)
-> 0.0051s
== 20220118015633 AddUrlTextToIssuableMetricImages: migrated (0.0052s) ========
== 20220118020026 AddUrlTextLimitToIssuableMetricImages: migrating ============
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0003s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE issuable_metric_images\nADD CONSTRAINT check_3bc6d47661\nCHECK ( char_length(url_text) <= 128 )\nNOT VALID;\n")
-> 0.0039s
-- current_schema()
-> 0.0004s
-- execute("SET statement_timeout TO 0")
-> 0.0011s
-- execute("ALTER TABLE issuable_metric_images VALIDATE CONSTRAINT check_3bc6d47661;")
-> 0.0017s
-- execute("RESET statement_timeout")
-> 0.0017s
== 20220118020026 AddUrlTextLimitToIssuableMetricImages: migrated (0.0291s) ===
Down:
== 20220118020026 AddUrlTextLimitToIssuableMetricImages: reverting ============
-- transaction_open?()
-> 0.0000s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE issuable_metric_images\nDROP CONSTRAINT IF EXISTS check_3bc6d47661\n")
-> 0.0091s
== 20220118020026 AddUrlTextLimitToIssuableMetricImages: reverted (0.0378s) ===
== 20220118015633 AddUrlTextToIssuableMetricImages: reverting =================
-- remove_column(:issuable_metric_images, :url_text, :text)
-> 0.0044s
== 20220118015633 AddUrlTextToIssuableMetricImages: reverted (0.0093s) ========
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
- Create an Incident via Monitor -> Incidents
- Upload a metric image via the UI or API: https://docs.gitlab.com/ee/api/issues.html#upload-metric-image
- Edit the URL and URL Text via the API:
curl --header "PRIVATE-TOKEN: <token>" --form 'file=@<path>' \ --form 'url=http://example.com' --form 'url_text=Example website' "http://gdk.test:3000/api/v4/projects/33/issues/1/metric_images"
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.
Related to #346171 (closed)
Edited by Sean Arnold