pedi3/database/migrations/2024_03_12_201127_create_ca...

39 lines
1.1 KiB
PHP

<?php
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::create('caracteristicas', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->string('key', 100);
$table->timestamps();
});
Schema::create('producto_caracteristica', function (Blueprint $table) {
$table->unsignedBigInteger('producto_id');
$table->unsignedBigInteger('caracteristica_id');
$table->primary(['producto_id','caracteristica_id']);
$table->foreign('producto_id')->references('id')->on('productos');
$table->foreign('caracteristica_id')->references('id')->on('caracteristicas');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('producto_caracteristica');
Schema::dropIfExists('caracteristicas');
}
};