-- Per-user redirect configuration. Human sessions go to `primary_url`;
-- suspicious/bot sessions go to `alternate_url` or see the block page.
CREATE TABLE IF NOT EXISTS `redirect_configs` (
    `id`            BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `user_id`       BIGINT UNSIGNED NOT NULL,
    `name`          VARCHAR(120)    NOT NULL DEFAULT 'Default',
    `primary_url`   VARCHAR(2048)   NOT NULL,
    `alternate_url` VARCHAR(2048)   NULL,
    `block_message` TEXT            NULL,
    `is_default`    TINYINT(1)      NOT NULL DEFAULT 0,
    `created_at`    DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`    DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `idx_redirect_user` (`user_id`),
    CONSTRAINT `fk_redirect_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
