<?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_auto_tariffs', static function (Blueprint $table) {
                $table->id();
                $table->string('name');
                $table->string('type');
                $table->integer('day_range_start');
                $table->integer('day_range_end');
                $table->integer('base_rate');
                $table->integer('deposit');
                $table->timestamps();
                $table->softDeletes();

                $table->unsignedBigInteger('model_id')->nullable()->comment('Тариф');
                $table->foreign('model_id')->references('id')->on('pipi_brand_models');
            });
        }
    }
};
