Refactor Brand, Category, Product, and ModelPropValue models to remove morph relationships; update migration files for props and model prop values to reflect new foreign key structure.

This commit is contained in:
2026-06-22 12:15:12 -03:00
parent 5c81d6997a
commit 93ebb0a110
8 changed files with 19 additions and 96 deletions

View File

@@ -14,15 +14,13 @@ return new class extends Migration
Schema::create('props', function (Blueprint $table) {
$table->id();
$table->string('propable_type');
$table->unsignedBigInteger('propable_id')->nullable();
$table->enum('scope', ['global', 'particular']);
$table->string('codigo')->unique();
$table->string('nombre');
$table->boolean('is_required')->default(false);
$table->foreignId('data_type_id')->constrained('props_data_types')->cascadeOnUpdate()->restrictOnDelete();
$table->timestamps();
$table->index(['propable_type', 'propable_id']);
$table->index('propable_type');
});
}

View File

@@ -13,20 +13,13 @@ return new class extends Migration
{
Schema::create('model_prop_values', function (Blueprint $table) {
$table->id();
$table->string('valuable_type');
$table->unsignedBigInteger('valuable_id');
$table->string('prop_codigo');
$table->foreignId('prop_id')->constrained('props')->cascadeOnUpdate()->cascadeOnDelete();
$table->text('value')->nullable();
$table->timestamps();
$table->foreign('prop_codigo')
->references('codigo')
->on('props')
->cascadeOnUpdate()
->cascadeOnDelete();
$table->unique(['valuable_type', 'valuable_id', 'prop_codigo']);
$table->index(['valuable_type', 'valuable_id']);
$table->unique(['prop_id', 'valuable_id']);
$table->index('valuable_id');
});
}