Files
Intelligent-selection-of-co…/database/migrations/2025_10_29_154421_create_components_table.php
dimon8 d8a8759504 crud
2026-01-07 19:29:49 +00:00

38 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('components', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->decimal('price', 10, 2);
$table->unsignedBigInteger('component_type_id'); // ссылка на тип компонента
$table->json('specifications')->nullable(); // JSON-поле для характеристик
$table->boolean('is_official')->default(false); // официальный или нет
$table->unsignedBigInteger('created_by_user_id')->nullable(); // кто создал
$table->timestamps();
$table->foreign('component_type_id')->references('id')->on('component_types');
$table->foreign('created_by_user_id')->references('id')->on('users')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('components');
}
};