<?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_applications', static function (Blueprint $table) {
                $table->id();
                $table->unsignedBigInteger('car_id')->nullable();
                $table->unsignedBigInteger('user_id')->nullable();
                $table->integer('rent_day')->nullable();
                $table->string('phone')->nullable();
                $table->dateTime('started_at')->nullable();
                $table->dateTime('ended_at')->nullable();
                $table->string('status')->nullable();
                $table->string('user_name')->nullable();
                $table->string('user_surname')->nullable();
                $table->string('user_email')->nullable();
                $table->timestamps();
                $table->softDeletes();
            });
        }
    }
};
