Skip to content

Fixes draft note race condition with whitespace changes

Phil Hughes requested to merge ph/340815/lineCodeToDraftNotes into master

What does this MR do and why?

Fixes a race condition with draft notes in that they would sometimes get displayed under every collapsed section. This gets caused by the line_code being returned as nil due to whitespace changes. To fix this issue we now save the line_code property into the database.

Migration down

== 20211122103051 AddLineCodeToDraftNotes: reverting ==========================
-- remove_column(:draft_notes, :line_code, :text)
   -> 0.0058s
== 20211122103051 AddLineCodeToDraftNotes: reverted (0.0102s) =================
== 20211124095704 AddDraftNotesLineCodeTextLimit: reverting ===================
-- transaction_open?()
   -> 0.0000s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE draft_notes\nDROP CONSTRAINT IF EXISTS check_c497a94a0e\n")
   -> 0.0019s
== 20211124095704 AddDraftNotesLineCodeTextLimit: reverted (0.0162s) ==========

Migration up

== 20211122103051 AddLineCodeToDraftNotes: migrating ==========================
-- add_column(:draft_notes, :line_code, :text)
   -> 0.0041s
== 20211122103051 AddLineCodeToDraftNotes: migrated (0.0042s) =================
== 20211124095704 AddDraftNotesLineCodeTextLimit: migrating ===================
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0005s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE draft_notes\nADD CONSTRAINT check_c497a94a0e\nCHECK ( char_length(line_code) <= 255 )\nNOT VALID;\n")
   -> 0.0057s
-- current_schema()
   -> 0.0002s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- execute("ALTER TABLE draft_notes VALIDATE CONSTRAINT check_c497a94a0e;")
   -> 0.0035s
-- execute("RESET statement_timeout")
   -> 0.0006s
== 20211124095704 AddDraftNotesLineCodeTextLimit: migrated (0.0299s) ==========

Screenshots or screen recordings

How to set up and validate locally

MR acceptance checklist

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

Closes #340815 (closed)

Edited by Phil Hughes

Merge request reports