CREATE TABLE commercial_license_cache ( instance_id text PRIMARY KEY, license_id text NOT NULL, signed_license text NOT NULL, edition text NOT NULL, features text[] NOT NULL DEFAULT '{}', max_s_instances integer NOT NULL CHECK (max_s_instances > 0), max_e_nodes integer NOT NULL CHECK (max_e_nodes > 0), expires_at timestamptz NOT NULL, offline_until timestamptz NOT NULL, status text NOT NULL CHECK (status IN ('active','revoked','expired')), last_verified_at timestamptz NOT NULL DEFAULT now(), created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now() ); CREATE INDEX commercial_license_cache_status_expiry_idx ON commercial_license_cache(status,expires_at);