-- Tables affected: stock_log
-- recovery.not-started: safe to re-run; CREATE TABLE IF NOT EXISTS
-- recovery.partial: DROP TABLE IF EXISTS stock_log;
-- recovery.completed: no action needed
-- verify: stock_log table missing | SELECT 1 FROM information_schema.TABLES WHERE table_schema=DATABASE() AND table_name='stock_log' HAVING COUNT(*)=0

CREATE TABLE IF NOT EXISTS stock_log (
    stock_log_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    lot VARCHAR(255) NOT NULL,
    supplier VARCHAR(255) NULL,
    date DATE NOT NULL,
    price DECIMAL(12,2) NOT NULL,
    quality VARCHAR(255) NULL,
    comments TEXT NULL,
    vendor VARCHAR(255) NULL,
    qty DECIMAL(14,3) NULL,
    INDEX idx_stock_log_lot_date (lot, date),
    INDEX idx_stock_log_date (date),
    INDEX idx_stock_log_vendor (vendor)
);
