pai-sklep/database/migrations/2021_12_08_183713_morph_images.php
2021-12-08 21:45:36 +01:00

35 lines
850 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AddCategories extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table("images", function(Blueprint $table) {
$table->uuidMorphs("imageable");
});
Schema::table("images", function(Blueprint $table) {
DB::table("images")->update(['imageable_id'=>DB::raw('`product_uuid`')], ['imageable_type' => "App\Models\Product"]);
$table->dropConstrainedForeignId("product_uuid");
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Ehh don't wanna bother
}
}