-- Copyright (C) 2026 Marcin Flaumenhaft
-- ScanStation module — scan log table

CREATE TABLE IF NOT EXISTS llx_scanstation_log (
    rowid          INT AUTO_INCREMENT PRIMARY KEY,
    fk_mo          INT NOT NULL,
    job_number     VARCHAR(64),
    fk_ws          INT,
    op_rank        INT,
    scan_type      VARCHAR(20) NOT NULL DEFAULT 'traveler',
    scanned_data   VARCHAR(512),
    qty_confirmed  DECIMAL(10,2) DEFAULT 1,
    fk_user        INT,
    date_scan      DATETIME NOT NULL,
    result         VARCHAR(20) DEFAULT 'ok',
    note           VARCHAR(255),
    entity         INT NOT NULL DEFAULT 1,
    INDEX idx_scanstation_log_fk_mo    (fk_mo),
    INDEX idx_scanstation_log_entity   (entity),
    INDEX idx_scanstation_log_date_scan(date_scan),
    INDEX idx_ss_log_mo_user           (fk_mo, fk_user)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
