<?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 dealer_visit_plans (
                id                          BIGINT GENERATED always AS IDENTITY PRIMARY KEY,

                employee_master_id          BIGINT NOT NULL,

                name                        TEXT DEFAULT NULL,
                company                     TEXT DEFAULT NULL,
                visit_plan_date             DATE DEFAULT NULL,
                organizer	                TEXT DEFAULT NULL,
                mobile_number               TEXT DEFAULT NULL,
                number_of_person	        TEXT DEFAULT NULL,
                purpose_of_visit            TEXT DEFAULT NULL,
                mode_of_travel              TEXT DEFAULT NULL,
                status	                    TEXT DEFAULT NULL,

                created_at                  TIMESTAMP NOT NULL DEFAULT NOW(),
                updated_at                  TIMESTAMP,
                deleted_at                  TIMESTAMP,

                created_by                  TEXT NULL,
                updated_by                  TEXT NULL,

                FOREIGN KEY (employee_master_id)    REFERENCES  employee_masters (id)
            );
        SQL;

        DB::statement($sql);
    }

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