<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        $sql = <<<'SQL'
            CREATE TABLE invoice_in_transits (
                id					               	BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
                plant_id							BIGINT NOT NULL,

                receiving_plant                     TEXT DEFAULT NULL,
                receiving_plant_name                TEXT DEFAULT NULL,
                invoice_number                      TEXT DEFAULT NULL,
                invoice_date                        TEXT DEFAULT NULL,
                item_code                           TEXT DEFAULT NULL,
                description                         TEXT DEFAULT NULL,
                quantity                            NUMERIC(10,3) DEFAULT NULL,
                transport_name                      TEXT DEFAULT NULL,
                lr_bl_aw_number                     TEXT DEFAULT NULL,
                lr_bl_aw_date                       TEXT DEFAULT NULL,
                pending_days                        TEXT DEFAULT NULL,
                obd_number                          TEXT DEFAULT NULL,
                obd_date                            TEXT DEFAULT NULL,
                shipment_weight                     TEXT DEFAULT NULL,
                unit_price                          TEXT DEFAULT NULL,
                net_value                           TEXT DEFAULT NULL,
                total_item_amount                   TEXT DEFAULT NULL,
                tax_amount                          TEXT DEFAULT NULL,
                transport_mode                      TEXT DEFAULT NULL,
                vehicle_number                      TEXT DEFAULT NULL,
                e_waybill_number                    TEXT DEFAULT NULL,

                created_at							TIMESTAMP NOT NULL DEFAULT NOW(),
                updated_at							TIMESTAMP NOT NULL DEFAULT NOW(),
                created_by							TEXT DEFAULT NULL,
                updated_by							TEXT DEFAULT NULL,
                deleted_at			                TIMESTAMP,

                FOREIGN KEY (plant_id)              REFERENCES  plants (id)
            );
        SQL;
        DB::statement($sql);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('invoice_in_transits');
    }
};
