Do not try to add the notes column if it already exists on accessories_users

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2021-06-19 16:20:22 -07:00
parent aae6a8fc6c
commit 0153c6ae96

View file

@ -14,10 +14,17 @@ class MoveAccessoryCheckoutNoteToJoinTable extends Migration
* @return void * @return void
*/ */
public function up() public function up()
{
if (!Schema::hasColumn('accessories_users', 'note'))
{ {
Schema::table('accessories_users', function (Blueprint $table) { Schema::table('accessories_users', function (Blueprint $table) {
$table->string('note')->nullable(true)->default(null); $table->string('note')->nullable(true)->default(null);
}); });
}
// Loop through the checked out accessories, find their related action_log entry, and copy over the note // Loop through the checked out accessories, find their related action_log entry, and copy over the note
// to the newly created note field // to the newly created note field
@ -82,8 +89,15 @@ class MoveAccessoryCheckoutNoteToJoinTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::table('accessories_users', function (Blueprint $table) {
if (Schema::hasColumn('accessories_users', 'note'))
{
Schema::table('accessories_users', function (Blueprint $table)
{
$table->dropColumn('note'); $table->dropColumn('note');
}); });
} }
}
} }