-- Cleanup orphaned API-related tables
-- Since admin panel is exclusively for Account Forger, we only need system_api_key table

-- Drop tables that depend on api_clients
DROP TABLE IF EXISTS rate_limits CASCADE;
DROP TABLE IF EXISTS license_events CASCADE;

-- Drop orphaned API tables
DROP TABLE IF EXISTS api_clients CASCADE;
DROP TABLE IF EXISTS api_keys CASCADE;

-- Add comments to document the single API key system
COMMENT ON TABLE system_api_key IS 'Single API key table for Account Forger authentication. This is the ONLY API key system in use.';

-- Log the cleanup
INSERT INTO audit_log (username, action, entity_type, details, ip_address)
VALUES ('SYSTEM', 'CLEANUP', 'database', 'Removed orphaned API tables: api_keys, api_clients, rate_limits, license_events', '127.0.0.1');