<?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'
            ALTER TABLE lines
            ADD COLUMN no_of_operation INT NOT NULL DEFAULT 0,

            ADD COLUMN work_group1_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group2_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group3_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group4_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group5_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group6_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group7_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group8_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group9_id BIGINT DEFAULT NULL,
            ADD COLUMN work_group10_id BIGINT DEFAULT NULL,
            ADD CONSTRAINT lines_work_group1_id_fkey
            FOREIGN KEY (work_group1_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group2_id_fkey
            FOREIGN KEY (work_group2_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group3_id_fkey
            FOREIGN KEY (work_group3_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group4_id_fkey
            FOREIGN KEY (work_group4_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group5_id_fkey
            FOREIGN KEY (work_group5_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group6_id_fkey
            FOREIGN KEY (work_group6_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group7_id_fkey
            FOREIGN KEY (work_group7_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group8_id_fkey
            FOREIGN KEY (work_group8_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group9_id_fkey
            FOREIGN KEY (work_group9_id) REFERENCES work_group_masters(id),
            ADD CONSTRAINT lines_work_group10_id_fkey
            FOREIGN KEY (work_group10_id) REFERENCES work_group_masters(id);

        SQL;

        DB::statement($sql);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Schema::table('lines', function (Blueprint $table) {
        //     //
        // });
    }
};
