summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-03-11 17:46:50 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-03-11 17:46:50 -0500
commit01f6db4f643380d143772958b22d3f318b1db3a7 (patch)
tree26fd4477e1ffc4149bece7d72687779de94d68a0 /db
parent70bf6dc702b6354c3a00d0b81e7d7c10be25ffb8 (diff)
downloadgitlab-ce-01f6db4f643380d143772958b22d3f318b1db3a7.tar.gz
Disallow blank (non-null) values for a Note's `line_code` attributers-disallow-blank-line-code
It's unclear how these blank values got added, but GitLab.com had a few: ``` irb(main):002:0> Note.where("line_code IS NOT NULL AND line_code = ''").count => 439 ``` We've added a migration to convert any existing records to use a NULL value when blank, and updated Note to set blank values to nil before validation.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20160307221555_disallow_blank_line_code_on_note.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/db/migrate/20160307221555_disallow_blank_line_code_on_note.rb b/db/migrate/20160307221555_disallow_blank_line_code_on_note.rb
new file mode 100644
index 00000000000..49e787d9a9a
--- /dev/null
+++ b/db/migrate/20160307221555_disallow_blank_line_code_on_note.rb
@@ -0,0 +1,9 @@
+class DisallowBlankLineCodeOnNote < ActiveRecord::Migration
+ def up
+ execute("UPDATE notes SET line_code = NULL WHERE line_code = ''")
+ end
+
+ def down
+ # noop
+ end
+end