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

CREATE TABLE IF NOT EXISTS stock_ignore_rules (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    target VARCHAR(20) NOT NULL,
    match_type VARCHAR(20) NOT NULL,
    pattern VARCHAR(500) NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY uq_stock_ignore_rule (target, match_type, pattern),
    KEY idx_stock_ignore_target (target)
);
