From e83dc752383e2ee98777daebe016c81b5d5f09c0 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Fri, 8 May 2020 10:43:23 +1000 Subject: [PATCH] FIX: Migration to set column NOT NULL for delete_when_reminder_sent on bookmarks (#9696) Also fix typo in original migration. Meta: https://meta.discourse.org/t/improved-bookmarks-with-reminders/144542/152?u=mjrbrennan --- ..._add_delete_when_reminder_sent_boolean_to_bookmarks.rb | 2 +- ..._ensure_bookmark_delete_when_reminder_sent_not_null.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rb 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.rb index 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: false end end diff --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.rb new file mode 100644 index 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