-- +goose Up
CREATE TABLE IF NOT EXISTS before_flight_inspections (
    id BINARY(16) PRIMARY KEY,
    flight_inspection_id BINARY(16) NOT NULL,
    oil_engine_nr1_checked TINYINT(1) NULL,
    oil_engine_nr2_checked TINYINT(1) NULL,
    hydraulic_lh_checked TINYINT(1) NULL,
    hydraulic_rh_checked TINYINT(1) NULL,
    oil_transmission_mgb_checked TINYINT(1) NULL,
    oil_transmission_igb_checked TINYINT(1) NULL,
    oil_transmission_tgb_checked TINYINT(1) NULL,
    fuel_amount DECIMAL(10,2) NULL,
    fuel_unit VARCHAR(10) NULL,
    fuel_added_amount DECIMAL(10,2) NULL,
    note TEXT NULL,
    created_at DATETIME NULL,
    created_by BINARY(16) NULL,
    updated_at DATETIME NULL,
    updated_by BINARY(16) NULL,
    CONSTRAINT fk_before_flight_inspections_flight_inspection FOREIGN KEY (flight_inspection_id) REFERENCES flight_inspections(id),
    CONSTRAINT chk_before_flight_fuel_unit CHECK (fuel_unit IS NULL OR fuel_unit IN ('LT', 'KG', 'POUND'))
);

CREATE UNIQUE INDEX idx_before_flight_inspections_flight_inspection_id ON before_flight_inspections(flight_inspection_id);

-- +goose Down
DROP TABLE IF EXISTS before_flight_inspections;
