mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Add migration
This commit is contained in:
parent
719463ef54
commit
165487ac92
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use App\Models\Asset;
|
||||
use App\Models\User;
|
||||
|
||||
class MakeAssetAssignedToPolymorphic extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
//
|
||||
$table->string('assigned_type')->nullable();
|
||||
});
|
||||
|
||||
// Prior to this migration, asset's could only be assigned to users.
|
||||
Asset::whereNotNull('assigned_to')->orWhere('assigned_to', '')->update(['assigned_type' => User::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('assigned_type');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue