Untitled

mail@pastecode.io avatar
unknown
plain_text
20 days ago
829 B
3
Indexable
Never
<?php

use App\Models\Model\Entity;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('entity_properties', function (Blueprint $table) {
            $table->dropForeign(['entity_id']);
            $table->dropColumn('entity_id');
            $table->morphs('propertiesable');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('entity_properties', function (Blueprint $table) {
            $table->dropMorphs('propertiesable');
            $table->foreignIdFor(Entity::class, 'entity_id')->constrained('entities');
        });
    }
};
Leave a Comment