From 7afeffc647ccd9f1ea92bc79159a8dfea32e15e2 Mon Sep 17 00:00:00 2001 From: clragon Date: Wed, 15 Jan 2025 17:09:29 +0100 Subject: [PATCH] [StaffNotes] Fix DB migration (#835) --- .rubocop.yml | 5 +---- db/migrate/20240205174652_soft_deletable_staff_notes.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 33c934fbc..b78883113 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -155,7 +155,4 @@ Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: consistent_comma Style/TrailingCommaInHashLiteral: - EnforcedStyleForMultiline: consistent_comma - -Rails/NotNullColumn: - Enabled: false + EnforcedStyleForMultiline: consistent_comma \ No newline at end of file diff --git a/db/migrate/20240205174652_soft_deletable_staff_notes.rb b/db/migrate/20240205174652_soft_deletable_staff_notes.rb index f5eb5e9e9..5d09d7518 100644 --- a/db/migrate/20240205174652_soft_deletable_staff_notes.rb +++ b/db/migrate/20240205174652_soft_deletable_staff_notes.rb @@ -1,9 +1,13 @@ # frozen_string_literal: true class SoftDeletableStaffNotes < ActiveRecord::Migration[7.1] - def change + def up add_column :staff_notes, :is_deleted, :boolean, null: false, default: false - add_reference :staff_notes, :updater, foreign_key: { to_table: :users }, null: false + + add_reference :staff_notes, :updater, foreign_key: { to_table: :users }, null: true + execute("UPDATE staff_notes SET updater_id = creator_id") + change_column_null :staff_notes, :updater_id, false + remove_column :staff_notes, :resolved, :boolean, null: false, default: false end end