From 69ff82616ce5b026236dab2bf8d102167bce1640 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Fri, 7 Jul 2023 14:58:54 -0400 Subject: [PATCH 1/3] Fix crash --- ...0612075547_add_kit_allocation_type_to_kit_allocations.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb b/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb index ef1605a186..0355359887 100644 --- a/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb +++ b/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb @@ -2,8 +2,10 @@ class AddKitAllocationTypeToKitAllocations < ActiveRecord::Migration[7.0] def change safety_assured do create_enum :kit_allocation_type, ["inventory_in", "inventory_out"] - change_table :kit_allocations do |t| - t.enum :kit_allocation_type, enum_type: "kit_allocation_type", default: "inventory_in", null: false + unless column_exists?(:kit_allocations, :kit_allocation_type) + change_table :kit_allocations do |t| + t.enum :kit_allocation_type, enum_type: "kit_allocation_type", default: "inventory_in", null: false + end end end end From ce99a86f28756bf7253c9aab2af8bbe7b1d089f1 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Fri, 7 Jul 2023 14:59:39 -0400 Subject: [PATCH 2/3] ahem --- ...2075547_add_kit_allocation_type_to_kit_allocations.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb b/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb index 0355359887..c4fd152f55 100644 --- a/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb +++ b/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb @@ -2,10 +2,11 @@ class AddKitAllocationTypeToKitAllocations < ActiveRecord::Migration[7.0] def change safety_assured do create_enum :kit_allocation_type, ["inventory_in", "inventory_out"] - unless column_exists?(:kit_allocations, :kit_allocation_type) - change_table :kit_allocations do |t| - t.enum :kit_allocation_type, enum_type: "kit_allocation_type", default: "inventory_in", null: false - end + if column_exists?(:kit_allocations, :kit_allocation_type) + remove_column :kit_allocations, :kit_allocation_type) + end + change_table :kit_allocations do |t| + t.enum :kit_allocation_type, enum_type: "kit_allocation_type", default: "inventory_in", null: false end end end From a1b4b41de196f5162a37b038c94edcf2568d8510 Mon Sep 17 00:00:00 2001 From: Daniel Orner Date: Fri, 7 Jul 2023 15:10:47 -0400 Subject: [PATCH 3/3] srsly --- ...20230612075547_add_kit_allocation_type_to_kit_allocations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb b/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb index c4fd152f55..e0a888cf8f 100644 --- a/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb +++ b/db/migrate/20230612075547_add_kit_allocation_type_to_kit_allocations.rb @@ -3,7 +3,7 @@ def change safety_assured do create_enum :kit_allocation_type, ["inventory_in", "inventory_out"] if column_exists?(:kit_allocations, :kit_allocation_type) - remove_column :kit_allocations, :kit_allocation_type) + remove_column :kit_allocations, :kit_allocation_type end change_table :kit_allocations do |t| t.enum :kit_allocation_type, enum_type: "kit_allocation_type", default: "inventory_in", null: false