From 6d68d87f22f810b32dd969cfef753146e8f6d237 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Wed, 11 Dec 2024 13:54:21 -0500 Subject: [PATCH] Change existing migration to create Category Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/TCO-125 How does this address that need: * Creates a Category "Flagged" if one does not already exist before trying to update data based on this specific Category Document any side effects to this change: * This migration has already run and it is normally not a good practice to update migrations to prevent databases from not bein in synch with the migration. In this case, all this does is introduce the code that was run manually in environments where this was run so it is fine and expected that those environments will not run it again. --- ...0241204214748_change_column_null_confirmation_category.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/migrate/20241204214748_change_column_null_confirmation_category.rb b/db/migrate/20241204214748_change_column_null_confirmation_category.rb index c7406da..22e67d4 100644 --- a/db/migrate/20241204214748_change_column_null_confirmation_category.rb +++ b/db/migrate/20241204214748_change_column_null_confirmation_category.rb @@ -1,5 +1,10 @@ class ChangeColumnNullConfirmationCategory < ActiveRecord::Migration[7.1] def change + Category.find_or_create_by( + name: 'Flagged', + description: 'A search which has sensitive information that should be excluded from further processing.' + ) + change_column_null :confirmations, :category_id, false, Category.find_by(name: 'Flagged').id end end