Fixed migration

This commit is contained in:
snipe 2016-12-29 17:26:50 -08:00
parent 16bd78fb3f
commit 0581499029

View file

@ -16,23 +16,21 @@ class MakeAssetAssignedToPolymorphic extends Migration
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]);
Asset::whereNotNull('assigned_to')->orWhere('assigned_to', '!=', '')->update(['assigned_type' => User::class]);
}
/**
* Reverse the migrations.
*
* @return void
* @return voidatom
*/
public function down()
{
Schema::table('assets', function (Blueprint $table) {
//
$table->dropColumn('assigned_type');
});
}