| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- /*
- * Миграция: создаёт таблицу cars — основная таблица каталога автомобилей.
- * Создана: 2026-05-06
- * Индексы: idx_make_model (поиск по марке/модели), idx_year, idx_status (фильтрация в списке)
- * photos_gallery — TEXT/JSON-массив путей к файлам (кастуется в array моделью Car)
- * options — TEXT/JSON-массив выбранных опций комплектации
- */
- return new class extends Migration
- {
- public function up(): void
- {
- Schema::create('cars', function (Blueprint $table) {
- $table->unsignedBigInteger('id')->autoIncrement();
- $table->enum('status', ['active', 'sold', 'draft'])->default('active');
- $table->enum('condition', ['new', 'used'])->default('used');
- $table->string('make', 64);
- $table->string('model', 64);
- $table->string('generation', 64)->nullable();
- $table->smallInteger('year')->unsigned();
- $table->string('vin', 17)->nullable();
- $table->string('plate', 20)->nullable();
- $table->string('body_type', 32)->nullable();
- $table->tinyInteger('doors')->unsigned()->nullable();
- $table->string('color_exterior', 32)->nullable();
- $table->string('color_interior', 32)->nullable();
- $table->enum('engine_type', ['petrol', 'diesel', 'hybrid', 'electric', 'gas', 'other'])->nullable();
- $table->decimal('engine_volume', 3, 1)->nullable();
- $table->smallInteger('engine_power_hp')->unsigned()->nullable();
- $table->enum('transmission', ['manual', 'automatic', 'robot', 'variator', 'electric'])->nullable();
- $table->enum('drive', ['FWD', 'RWD', 'AWD', '4WD'])->nullable();
- $table->unsignedInteger('mileage_km')->nullable();
- $table->enum('steering', ['left', 'right'])->default('left');
- $table->tinyInteger('owners_count')->unsigned()->nullable();
- $table->boolean('customs_cleared')->default(true);
- $table->enum('pts', ['original', 'duplicate', 'electronic'])->nullable();
- $table->boolean('accident_free')->default(false);
- $table->unsignedInteger('price_usd')->nullable();
- $table->unsignedBigInteger('price_rub')->nullable();
- $table->unsignedBigInteger('price_vladivostok')->nullable();
- $table->unsignedBigInteger('price_moscow')->nullable();
- $table->boolean('price_negotiable')->default(false);
- $table->string('country_origin', 64)->nullable();
- $table->string('city', 64)->nullable();
- $table->text('options')->nullable();
- $table->string('title', 128)->nullable();
- $table->text('description')->nullable();
- $table->string('photo_main', 512)->nullable();
- $table->text('photos_gallery')->nullable()->comment('JSON array of paths');
- $table->timestamps();
- $table->index(['make', 'model'], 'idx_make_model');
- $table->index('year', 'idx_year');
- $table->index('status', 'idx_status');
- });
- }
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('cars');
- }
- };
|