Add conditionals

This commit is contained in:
Marcus Moore 2023-01-23 15:42:33 -08:00
parent e6dc61d2cf
commit 760844de6f
No known key found for this signature in database

View file

@ -48,13 +48,19 @@ class MigrateMacAddress extends Migration
*/ */
public function down() public function down()
{ {
//
$f = \App\Models\CustomFieldset::where(['name' => 'Asset with MAC Address'])->first(); $f = \App\Models\CustomFieldset::where(['name' => 'Asset with MAC Address'])->first();
$f->fields()->delete();
$f->delete(); if ($f) {
$f->fields()->delete();
$f->delete();
}
Schema::table('models', function (Blueprint $table) { Schema::table('models', function (Blueprint $table) {
$table->renameColumn('deprecated_mac_address', 'show_mac_address'); $table->renameColumn('deprecated_mac_address', 'show_mac_address');
}); });
DB::statement('ALTER TABLE assets CHANGE _snipeit_mac_address_1 mac_address varchar(255)');
if (Schema::hasColumn('assets', '_snipeit_mac_address')) {
DB::statement('ALTER TABLE assets CHANGE _snipeit_mac_address mac_address varchar(255)');
}
} }
} }