pedi3/database/migrations/2024_03_12_201127_create_ca...

39 lines
1.1 KiB
PHP
Raw Normal View History

2024-03-12 17:17:42 -03:00
<?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);
2024-03-12 22:27:02 -03:00
$table->string('key', 100);
2024-03-12 17:17:42 -03:00
$table->timestamps();
});
2024-03-15 01:34:41 -03:00
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');
});
2024-03-12 17:17:42 -03:00
}
/**
* Reverse the migrations.
*/
public function down(): void
{
2024-03-15 01:34:41 -03:00
Schema::dropIfExists('producto_caracteristica');
2024-03-12 17:17:42 -03:00
Schema::dropIfExists('caracteristicas');
}
};