This commit is contained in:
dimon8
2026-01-07 19:29:49 +00:00
parent 31b79d70c5
commit d8a8759504
14 changed files with 363 additions and 78 deletions

View File

@@ -11,16 +11,19 @@ return new class extends Migration
*/
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();
});
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');
});
}

View File

@@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->text('custom_field');
$table->text('custom_field')->nullable()->default(null);
//
});
}

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePcBuildComponentsTable extends Migration
{
public function up()
{
Schema::create('pc_build_components', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('pc_build_id');
$table->unsignedBigInteger('component_id');
$table->timestamps();
// Внешние ключи
$table->foreign('pc_build_id')->references('id')->on('pc_builds')->onDelete('cascade');
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
// Уникальность пары (build + component), если нужно
$table->unique(['pc_build_id', 'component_id']);
});
}
public function down()
{
Schema::dropIfExists('pc_build_components');
}
}

View File

@@ -0,0 +1,61 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
{
Schema::create('ai_tasks', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained()->onDelete('set null');
$table->string('name');
$table->text('prompt_template');
$table->boolean('is_active')->default(true);
$table->timestamps();
// Индекс для поиска активных шаблонов
$table->index(['is_active']);
});
// Заполняем базовыми шаблонами от админа (user_id = NULL)
DB::table('ai_tasks')->insert([
[
'name' => 'Игровой ПК до 50 000 ₽',
'prompt_template' => 'Собери бюджетный игровой ПК до 50000 рублей. Цель: игры на средних настройках в 1080p.',
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'name' => 'Игровой ПК до 100 000 ₽',
'prompt_template' => 'Собери мощный игровой ПК до 100000 рублей. Цель: игры на ультра в 1440p, 60+ FPS.',
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'name' => 'Офисный ПК',
'prompt_template' => 'Собери надёжный ПК для офиса и учёбы. Бюджет до 40000 рублей. Важна тишина и энергоэффективность.',
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
],
]);
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ai_tasks');
}
};