From 0153c6ae96833a195865a97753154e2c11c7e436 Mon Sep 17 00:00:00 2001
From: snipe <snipe@snipe.net>
Date: Sat, 19 Jun 2021 16:20:22 -0700
Subject: [PATCH] Do not try to add the notes column if it already exists on
 accessories_users

Signed-off-by: snipe <snipe@snipe.net>
---
 ..._accessory_checkout_note_to_join_table.php | 26 ++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php b/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php
index bfa9a7e36..d2e087d9b 100644
--- a/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php
+++ b/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php
@@ -15,9 +15,16 @@ class MoveAccessoryCheckoutNoteToJoinTable extends Migration
      */
     public function up()
     {
-        Schema::table('accessories_users', function (Blueprint $table) {
-            $table->string('note')->nullable(true)->default(null);
-        });
+
+        if (!Schema::hasColumn('accessories_users', 'note'))
+        {
+            Schema::table('accessories_users', function (Blueprint $table) {
+                $table->string('note')->nullable(true)->default(null);
+            });
+        }
+
+
+        
 
         // Loop through the checked out accessories, find their related action_log entry, and copy over the note
         // to the newly created note field
@@ -82,8 +89,15 @@ class MoveAccessoryCheckoutNoteToJoinTable extends Migration
      */
     public function down()
     {
-        Schema::table('accessories_users', function (Blueprint $table) {
-            $table->dropColumn('note');
-        });
+
+        if (Schema::hasColumn('accessories_users', 'note'))
+        {
+            Schema::table('accessories_users', function (Blueprint $table)
+            {
+                $table->dropColumn('note');
+            });
+        }
+
+    
     }
 }
-- 
GitLab