pai-sklep/database/migrations/2021_12_08_183713_make_imag...

36 lines
852 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class MakeImagesMorph 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
}
}