-- Migration 006: page categorisation / tagging per project
CREATE TABLE IF NOT EXISTS page_categories (
    id                   INT UNSIGNED    NOT NULL AUTO_INCREMENT PRIMARY KEY,
    project_id           INT             NOT NULL,
    name                 VARCHAR(80)     NOT NULL,
    color                VARCHAR(20)     NOT NULL DEFAULT 'secondary',
    match_type           ENUM('noise_builtin','path_prefix','regex','url_list') NOT NULL DEFAULT 'path_prefix',
    match_value          TEXT            NULL COMMENT 'Prefix string, regex pattern, or newline-separated URL list',
    exclude_from_filters TINYINT(1)      NOT NULL DEFAULT 0 COMMENT '1 = hide these pages when noise filter is ON',
    sort_order           SMALLINT        NOT NULL DEFAULT 0,
    created_at           TIMESTAMP       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_pc_project (project_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
