From 165487ac929bdcdbd80a437dcff6621eb7b983c9 Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Tue, 27 Dec 2016 22:04:30 -0500 Subject: [PATCH] Add migration --- ...631_make_asset_assigned_to_polymorphic.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 database/migrations/2016_12_27_212631_make_asset_assigned_to_polymorphic.php diff --git a/database/migrations/2016_12_27_212631_make_asset_assigned_to_polymorphic.php b/database/migrations/2016_12_27_212631_make_asset_assigned_to_polymorphic.php new file mode 100644 index 0000000000..a00692c7b1 --- /dev/null +++ b/database/migrations/2016_12_27_212631_make_asset_assigned_to_polymorphic.php @@ -0,0 +1,39 @@ +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'); + }); + } +}