<?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 class_characteristics (
                id					                BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
                plant_id						    BIGINT NOT NULL,
                machine_id                          BIGINT NOT NULL,
                item_id							    BIGINT NOT NULL,
                aufnr                               TEXT DEFAULT NULL,
                class                               TEXT DEFAULT NULL,
                arbid                               TEXT DEFAULT NULL,
                gamng                               TEXT DEFAULT NULL,
                lmnga                               TEXT DEFAULT NULL,
                gernr                               TEXT DEFAULT NULL,
                zz1_cn_bill_ord                     TEXT DEFAULT NULL,
                zmm_amps                            TEXT DEFAULT NULL,
                zmm_brand                           TEXT DEFAULT NULL,
                zmm_degreeofprotection              TEXT DEFAULT NULL,
                zmm_delivery                        TEXT DEFAULT NULL,
                zmm_dir_rot                         TEXT DEFAULT NULL,
                zmm_discharge                       TEXT DEFAULT NULL,
                zmm_discharge_max                   TEXT DEFAULT NULL,
                zmm_discharge_min                   TEXT DEFAULT NULL,
                zmm_duty                            TEXT DEFAULT NULL,
                zmm_eff_motor                       TEXT DEFAULT NULL,
                zmm_eff_pump                        TEXT DEFAULT NULL,
                zmm_frequency                       TEXT DEFAULT NULL,
                zmm_head                            TEXT DEFAULT NULL,
                zmm_heading                         TEXT DEFAULT NULL,
                zmm_head_max                        TEXT DEFAULT NULL,
                zmm_head_minimum                    TEXT DEFAULT NULL,
                zmm_idx_eff_mtr                     TEXT DEFAULT NULL,
                zmm_idx_eff_pump                    TEXT DEFAULT NULL,
                zmm_kvacode                         TEXT DEFAULT NULL,
                zmm_maxambtemp                      TEXT DEFAULT NULL,
                zmm_mincoolingflow                  TEXT DEFAULT NULL,
                zmm_motorseries                     TEXT DEFAULT NULL,
                zmm_motor_model                     TEXT DEFAULT NULL,
                zmm_outlet                          TEXT DEFAULT NULL,
                zmm_phase                           TEXT DEFAULT NULL,
                zmm_pressure                        TEXT DEFAULT NULL,
                zmm_pumpflowtype                    TEXT DEFAULT NULL,
                zmm_pumpseries                      TEXT DEFAULT NULL,
                zmm_pump_model                      TEXT DEFAULT NULL,
                zmm_ratedpower                      TEXT DEFAULT NULL,
                zmm_region                          TEXT DEFAULT NULL,
                zmm_servicefactor                   TEXT DEFAULT NULL,
                zmm_servicefactormaximumamps        TEXT DEFAULT NULL,
                zmm_speed                           TEXT DEFAULT NULL,
                zmm_suction                         TEXT DEFAULT NULL,
                zmm_suctionxdelivery                TEXT DEFAULT NULL,
                zmm_supplysource                    TEXT DEFAULT NULL,
                zmm_temperature                     TEXT DEFAULT NULL,
                zmm_thrustload                      TEXT DEFAULT NULL,
                zmm_volts                           TEXT DEFAULT NULL,
                zmm_wire                            TEXT DEFAULT NULL,
                zmm_package                         TEXT DEFAULT NULL,
                zmm_pvarrayrating                   TEXT DEFAULT NULL,
                zmm_isi                             TEXT DEFAULT NULL,
                zmm_isimotor                        TEXT DEFAULT NULL,
                zmm_isipump                         TEXT DEFAULT NULL,
                zmm_isipumpset                      TEXT DEFAULT NULL,
                zmm_pumpset_model                   TEXT DEFAULT NULL,
                zmm_stages                          TEXT DEFAULT NULL,
                zmm_headrange                       TEXT DEFAULT NULL,
                zmm_overall_efficiency              TEXT DEFAULT NULL,
                zmm_connection                      TEXT DEFAULT NULL,
                zmm_min_bore_size                   TEXT DEFAULT NULL,
                zmm_isireference                    TEXT DEFAULT NULL,
                zmm_category                        TEXT DEFAULT NULL,
                zmm_submergence                     TEXT DEFAULT NULL,
                zmm_capacitorstart                  TEXT DEFAULT NULL,
                zmm_capacitorrun                    TEXT DEFAULT NULL,
                zmm_inch                            TEXT DEFAULT NULL,
                zmm_motor_type                      TEXT DEFAULT NULL,
                zmm_dismantle_direction             TEXT DEFAULT NULL,
                zmm_eff_ovrall                      TEXT DEFAULT NULL,
                zmm_bodymoc                         TEXT DEFAULT NULL,
                zmm_rotormoc                        TEXT DEFAULT NULL,
                zmm_dlwl                            TEXT DEFAULT NULL,
                zmm_inputpower                      TEXT DEFAULT NULL,
                zmm_imp_od                          TEXT DEFAULT NULL,
                zmm_ambtemp                         TEXT DEFAULT NULL,
                zmm_de                              TEXT DEFAULT NULL,
                zmm_dischargerange                  TEXT DEFAULT NULL,
                zmm_efficiency_class                TEXT DEFAULT NULL,
                zmm_framesize                       TEXT DEFAULT NULL,
                zmm_impellerdiameter                TEXT DEFAULT NULL,
                zmm_insulationclass                 TEXT DEFAULT NULL,
                zmm_maxflow                         TEXT DEFAULT NULL,
                zmm_minhead                         TEXT DEFAULT NULL,
                zmm_mtrlofconst                     TEXT DEFAULT NULL,
                zmm_nde                             TEXT DEFAULT NULL,
                zmm_powerfactor                     TEXT DEFAULT NULL,
                zmm_tagno                           TEXT DEFAULT NULL,
                zmm_year                            TEXT DEFAULT NULL,
                zmm_laser_name                      TEXT DEFAULT NULL,
                zmm_beenote                         TEXT DEFAULT NULL,
                zmm_beenumber                       TEXT DEFAULT NULL,
                zmm_beestar                         TEXT DEFAULT NULL,
                zmm_logo_ce                         TEXT DEFAULT NULL,
                zmm_codeclass                       TEXT DEFAULT NULL,
                zmm_colour                          TEXT DEFAULT NULL,
                zmm_logo_cp                         TEXT DEFAULT NULL,
                zmm_grade                           TEXT DEFAULT NULL,
                zmm_grwt_pset                       TEXT DEFAULT NULL,
                zmm_grwt_cable                      TEXT DEFAULT NULL,
                zmm_grwt_motor                      TEXT DEFAULT NULL,
                zmm_grwt_pf                         TEXT DEFAULT NULL,
                zmm_grwt_pump                       TEXT DEFAULT NULL,
                zmm_isivalve                        TEXT DEFAULT NULL,
                zmm_isi_wc                          TEXT DEFAULT NULL,
                zmm_labelperiod                     TEXT DEFAULT NULL,
                zmm_length                          TEXT DEFAULT NULL,
                zmm_license_cml_no                  TEXT DEFAULT NULL,
                zmm_mfgmonyr                        TEXT DEFAULT NULL,
                zmm_modelyear                       TEXT DEFAULT NULL,
                zmm_motoridentification             TEXT DEFAULT NULL,
                zmm_newt_pset                       TEXT DEFAULT NULL,
                zmm_newt_cable                      TEXT DEFAULT NULL,
                zmm_newt_motor                      TEXT DEFAULT NULL,
                zmm_newt_pf                         TEXT DEFAULT NULL,
                zmm_newt_pump                       TEXT DEFAULT NULL,
                zmm_logo_nsf                        TEXT DEFAULT NULL,
                zmm_packtype                        TEXT DEFAULT NULL,
                zmm_panel                           TEXT DEFAULT NULL,
                zmm_performance_factor              TEXT DEFAULT NULL,
                zmm_pumpidentification              TEXT DEFAULT NULL,
                zmm_psettype                        TEXT DEFAULT NULL,
                zmm_size                            TEXT DEFAULT NULL,
                zmm_eff_ttl                         TEXT DEFAULT NULL,
                zmm_type                            TEXT DEFAULT NULL,
                zmm_usp                             TEXT DEFAULT NULL,
                mark_status                         TEXT DEFAULT NULL,
                marked_datetime                     TIMESTAMP DEFAULT NULL,
                marked_by                           TEXT DEFAULT NULL,
                man_marked_status                   TEXT DEFAULT NULL,
                man_marked_datetime                 TIMESTAMP DEFAULT NULL,
                man_marked_by                       TEXT DEFAULT NULL,
                motor_marked_status                 TEXT DEFAULT NULL,
                pump_marked_status                  TEXT DEFAULT NULL,
                motor_pump_pumpset_status           TEXT DEFAULT NULL,
                part_validation_1                   TEXT DEFAULT NULL,
                part_validation_2                   TEXT DEFAULT NULL,
                samlight_logged_name                TEXT DEFAULT NULL,
                pending_released_status             INTEGER DEFAULT 0,
                expected_time                       TEXT DEFAULT '0',

                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),
                FOREIGN KEY (machine_id)            REFERENCES  machines (id),
                FOREIGN KEY (item_id)               REFERENCES  items(id)
            );
        SQL;
        DB::statement($sql);
    }

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