<?php
declare(strict_types=1);

function golder_ensure_scanner_table(PDO $master): void
{
    $master->exec(
        "CREATE TABLE IF NOT EXISTS remote_scan_requests (
            id CHAR(36) PRIMARY KEY,
            customer_id BIGINT NOT NULL,
            target_device_id BIGINT NOT NULL,
            status VARCHAR(20) NOT NULL DEFAULT 'pending', /* pending, completed, cancelled */
            barcode_data VARCHAR(150) DEFAULT NULL,
            created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
            expires_at DATETIME NOT NULL,
            KEY idx_scanner_device (target_device_id, status)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
    );
}


