A platform for community discussion. Free, open, simple.
FIX: Migration to set column NOT NULL for delete_when_reminder_sent on bookmarks (#9696)
Martin Brennane83dc752383e
diff --git a/db/migrate/20200505060712_add_delete_when_reminder_sent_boolean_to_bookmarks.rb b/db/migrate/20200505060712_add_delete_when_reminder_sent_boolean_to_bookmarks.rbindex 7e4ca807fa3..66976ff4e5e 100644--- a/db/migrate/20200505060712_add_delete_when_reminder_sent_boolean_to_bookmarks.rb+++ b/db/migrate/20200505060712_add_delete_when_reminder_sent_boolean_to_bookmarks.rb@@ -2,6 +2,6 @@class AddDeleteWhenReminderSentBooleanToBookmarks < ActiveRecord::Migration[6.0]def change- add_column :bookmarks, :delete_when_reminder_sent, :boolean, nullabe: false, default: false+ add_column :bookmarks, :delete_when_reminder_sent, :boolean, null: false, default: falseendenddiff --git a/db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rb b/db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rbnew file mode 100644index 00000000000..5052675f969--- /dev/null+++ b/db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rb@@ -0,0 +1,8 @@+# frozen_string_literal: true++class EnsureBookmarkDeleteWhenReminderSentNotNull < ActiveRecord::Migration[6.0]+ def change+ DB.exec("UPDATE bookmarks SET delete_when_reminder_sent = false WHERE delete_when_reminder_sent IS NULL")+ change_column_null :bookmarks, :delete_when_reminder_sent, false+ end+end