pipicar/modules/owners/migrate.php

45 lines
2.5 KiB
PHP

<?php
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
$segments = Segment::listActive();
foreach ($segments as $segment) {
Schema::connection($segment->connector)->create('pipi_owners', static function (Blueprint $table) {
$table->id();
$table->string('name')->nullable()->comment('Наименование');
$table->boolean('is_group')->default(false)->comment('Это группа');
$table->string('code')->nullable()->comment('Код');
$table->string('iin')->nullable()->comment('ИИН');
$table->string('kbe')->nullable()->comment('КБЕ');
$table->string('okpo_code')->nullable()->comment('Код по ОКПО');
$table->string('comments')->nullable()->comment('Комментарий');
$table->string('main_contact')->nullable()->comment('Основное контактное лицо');
$table->string('bank_account')->nullable()->comment('Оснойной банковский счет');
$table->string('address')->nullable()->comment('Адрес');
$table->string('phone')->nullable()->comment('Телефон');
$table->string('mail')->nullable()->comment('Почта');
$table->string('id_number')->nullable()->comment('Номер удостоверения');
$table->date('id_date')->nullable()->comment('Дата удостоверения');
$table->string('issued')->nullable()->comment('Удостоверение выдано');
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('contract_id')->nullable()->comment('id Договора');
$table->foreign('contract_id')->references('id')->on('pipi_owner_contracts')->onDelete('cascade');
$table->unsignedBigInteger('parent_id')->nullable()->comment('Парент');
$table->foreign('parent_id')->references('id')->on('pipi_owners');
$table->unsignedBigInteger('user_id')->nullable()->comment('Пользователь в системе');
$table->foreign('user_id')->references('id')->on('core_users');
});
}
}
};