upgrade(); } private function upgrade(): void { $segments = Segment::listActive(); foreach ($segments as $segment) { if (!Schema::connection($segment->connector)->hasTable('pipi_auto')) { Schema::connection($segment->connector)->create('pipi_auto', static function (Blueprint $table) { $table->id(); $table->string('link')->nullable()->comment('Ссылка'); $table->string('code')->unique()->comment('Код'); $table->string('name')->nullable()->comment('Наименование'); $table->unsignedBigInteger('type_id')->nullable()->comment('Тип'); $table->unsignedBigInteger('class_id')->nullable()->comment('Класс'); $table->unsignedBigInteger('brand_id')->nullable()->comment('Марка'); $table->unsignedBigInteger('model_id')->nullable()->comment('Модель'); $table->unsignedBigInteger('color_id')->nullable()->comment('Цвет'); $table->string('serial_number')->nullable()->comment('Серийный номер'); $table->string('state_number')->nullable()->comment('Госномер'); $table->date('manufacture_year')->nullable()->comment('Год производства'); $table->string('passport_number')->nullable()->comment('Номер техпаспорта'); $table->date('passport_date')->nullable()->comment('Дата техпаспорта'); $table->unsignedBigInteger('estimated_cost')->nullable()->comment('Оценочная стоимость'); $table->unsignedBigInteger('owner_id')->nullable()->comment('Владелец имущества'); $table->boolean('is_trust_management')->default(false)->comment('В доверенном управлении'); $table->integer('owner_percentage')->nullable()->comment('Процент владельца'); $table->string('owner_contract')->nullable()->comment('Договор владельца имущества'); $table->unsignedBigInteger('owner_contract_id')->nullable()->comment('Договор владельца'); $table->boolean('is_inactive')->default(false)->comment('Не использовать'); $table->text('inspection_kit_container')->nullable()->comment('Комплектация для осмотра (контейнер)'); $table->text('inspection_kit')->nullable()->comment('Комплектация для осмотра'); $table->boolean('is_predefined')->default(false)->comment('Предопределенный'); $table->string('predefined_data_name')->nullable()->comment('Имя предопределенных данных'); $table->string('representation')->nullable()->comment('Представление'); $table->timestamps(); $table->softDeletes(); // Внешние ключи $table->foreign('type_id')->references('id')->on('pipi_auto_types'); $table->foreign('class_id')->references('id')->on('pipi_auto_classes'); $table->foreign('brand_id')->references('id')->on('pipi_auto_brands'); $table->foreign('model_id')->references('id')->on('pipi_brand_models'); $table->foreign('color_id')->references('id')->on('pipi_auto_colors'); $table->foreign('owner_id')->references('id')->on('pipi_owners'); $table->foreign('owner_contract_id')->references('id')->on('pipi_contracts'); }); } } } };