35 lines
1.1 KiB
PHP
35 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'); // Например: "Intel Core i5-12400F"
|
|
$table->foreignId('component_type_id')->constrained()->onDelete('cascade');
|
|
$table->decimal('price', 10, 2);
|
|
$table->json('specifications')->nullable(); // Для хранения характеристик
|
|
$table->boolean('is_official')->default(true); // true = админ, false = пользователь
|
|
$table->foreignId('created_by_user_id')->nullable()->constrained('users')->onDelete('set null');
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('components');
|
|
}
|
|
};
|