-- +goose Up
CREATE TABLE IF NOT EXISTS after_flight_inspections (
    id BINARY(16) PRIMARY KEY,
    flight_inspection_id BINARY(16) NOT NULL,
    ac_oil_upload_liter DECIMAL(10,2) 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,
    note TEXT NULL,
    created_at DATETIME NULL,
    created_by BINARY(16) NULL,
    updated_at DATETIME NULL,
    updated_by BINARY(16) NULL,
    CONSTRAINT fk_after_flight_inspections_flight_inspection FOREIGN KEY (flight_inspection_id) REFERENCES flight_inspections(id),
    CONSTRAINT chk_after_flight_ac_oil_upload_liter CHECK (ac_oil_upload_liter IS NULL OR ac_oil_upload_liter >= 0)
);

CREATE UNIQUE INDEX idx_after_flight_inspections_flight_inspection_id ON after_flight_inspections(flight_inspection_id);

-- +goose Down
DROP TABLE IF EXISTS after_flight_inspections;
