<?php

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

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        /* Schema::create('Clients', function (Blueprint $table) {
            $table->increments('ID');
            $table->decimal('Client_ID', 18, 0)->nullable();
            $table->string('Client_Name', 50)->nullable();
            $table->string('User_Name', 50)->nullable();
            $table->string('Password', 100)->nullable();
            $table->char('Delete_Flag', 10)->nullable();
            $table->dateTime('Delete_Date')->nullable();
            $table->string('Delete_User', 50)->nullable();
        }); */

        Schema::create('Order_Details', function (Blueprint $table) {
            $table->increments('ID');
            $table->decimal('Client_ID', 18, 0)->nullable();
            $table->string('Order_Number', 50)->nullable();
            $table->string('Type', 50)->nullable();
            $table->string('Quantity', 50)->nullable();
            $table->string('Notes', 500)->nullable();
            $table->char('Delete_Flag', 10)->nullable();
            $table->dateTime('Delete_Date')->nullable();
            $table->string('Delete_User', 50)->nullable();
        });

        Schema::create('Order_Main', function (Blueprint $table) {
            $table->increments('ID')->startingFrom(101);
            $table->decimal('Client_ID', 18, 0)->nullable();
            //$table->unsignedBigInteger('Order_Number'); //->unique()->startingFrom(101)->increment(1);
            $table->dateTime('Entry_Date')->nullable();
            $table->dateTime('Deadline_Date')->nullable();
            $table->string('Description', 500)->nullable();
            $table->string('Status', 50)->nullable();
            $table->string('Category', 50)->nullable();
            $table->string('Collection', 50)->nullable();
            $table->string('Gold_Color', 50)->nullable();
            $table->string('Size', 50)->nullable();
            $table->text('Remarks')->nullable();
            $table->text('Image')->nullable();
            $table->char('Delete_Flag', 10)->nullable();
            $table->dateTime('Delete_Date')->nullable();
            $table->string('Delete_User', 50)->nullable();
        });
        // Set a default value of 101 for Order_Number
        //DB::statement("ALTER TABLE Order_Main ADD CONSTRAINT DF_Order_Main_ID DEFAULT 101 FOR ID");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('Order_Main');

        Schema::dropIfExists('Order_Details');

        Schema::dropIfExists('Clients');
    }
};