SET NAMES utf8mb4; CREATE TABLE IF NOT EXISTS admin_sessions ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, admin_user_id BIGINT UNSIGNED NOT NULL, refresh_token_hash BINARY(32) NOT NULL, user_agent_hash BINARY(32) NOT NULL, ip VARCHAR(45) NOT NULL DEFAULT '', expires_at DATETIME(3) NOT NULL, last_active_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), revoked_at DATETIME(3) NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY (id), UNIQUE KEY uk_admin_sessions_refresh (refresh_token_hash), KEY idx_admin_sessions_user (admin_user_id, revoked_at, expires_at), CONSTRAINT fk_admin_sessions_user FOREIGN KEY (admin_user_id) REFERENCES admin_users(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;