From 07ec46e15187175d6fbdf5dfac22fac8ea960f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Mon, 30 Nov 2020 15:41:04 +0100 Subject: [PATCH] Enforce GUID being present for notifications --- ...142541_change_notifications_guid_not_null.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 db/migrate/20201130142541_change_notifications_guid_not_null.rb diff --git a/db/migrate/20201130142541_change_notifications_guid_not_null.rb b/db/migrate/20201130142541_change_notifications_guid_not_null.rb new file mode 100644 index 000000000..32603c195 --- /dev/null +++ b/db/migrate/20201130142541_change_notifications_guid_not_null.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class ChangeNotificationsGuidNotNull < ActiveRecord::Migration[5.2] + def up + Notification.where(guid: nil).find_in_batches do |batch| + batch.each do |notification| + notification.save!(validate: false, touch: false) + end + end + + change_column :notifications, :guid, :string, null: false + end + + def down + change_column :notifications, :guid, :string, null: true + end +end