CREATE TABLE IF NOT EXISTS oauth_codes (
    id_code INT UNSIGNED NOT NULL AUTO_INCREMENT,
    code CHAR(64) NOT NULL,
    id_user INT UNSIGNED NOT NULL,
    redirect_uri VARCHAR(255) NOT NULL,
    device VARCHAR(190) NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    expires_at DATETIME NOT NULL,
    used_at DATETIME NULL,
    PRIMARY KEY (id_code),
    UNIQUE KEY uniq_code (code),
    KEY idx_user (id_user)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
