CREATE TABLE IF NOT EXISTS travel_1_magic_login_tokens (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    user_id BIGINT UNSIGNED NOT NULL,
    token_hash CHAR(64) NOT NULL,
    expires_at DATETIME NOT NULL,
    used_at DATETIME NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    KEY idx_magic_login_tokens_user (user_id),
    KEY idx_magic_login_tokens_expiry (expires_at),
    CONSTRAINT fk_magic_login_tokens_user FOREIGN KEY (user_id)
        REFERENCES travel_1_users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
