<?php

return <<<'SQL'
CREATE TABLE scan_import_jobs (
    id CHAR(36) NOT NULL PRIMARY KEY,
    tenant_id CHAR(36) NOT NULL,
    uploaded_by_user_id CHAR(36) NOT NULL,
    source_filename VARCHAR(255) NOT NULL,
    source_path VARCHAR(255) NOT NULL,
    status VARCHAR(50) NOT NULL DEFAULT 'uploaded',
    template_id CHAR(36) NULL,
    error_message TEXT NULL,
    processed_at DATETIME NULL,
    posted_at DATETIME NULL,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    INDEX scan_import_jobs_tenant_status_idx (tenant_id, status),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id),
    FOREIGN KEY (uploaded_by_user_id) REFERENCES users(id)
);
SQL;
