migrate_kg_uuids
One-time migration: assign UUID7 to all KG entities and stamp src_uuid / tgt_uuid on all relationships.
Idempotent – only touches nodes/edges where the uuid fields are NULL.
Usage:
python migrate_kg_uuids.py [--redis-url redis://localhost:6379/0]
- async migrate_kg_uuids.migrate(redis_url, ssl_kwargs=None)[source]
Backfill UUID7 identifiers across the knowledge graph.
Walks the
knowledgeFalkorDB graph and, in three steps, assigns a freshuuid7to every entity whoseuuidproperty is NULL, then stampssrc_uuid/tgt_uuidonto every relationship from its endpoints’ UUIDs, then verifies that no nodes or edges remain unstamped. The migration is idempotent: only NULL fields are touched, so re-running it leaves already-stamped records alone.Opens an async Redis connection at
redis_url(its pool also backing theFalkorDBclient named byGRAPH_NAME) and issues per-node and bulk Cypherquerycalls; entity UUIDs are written one node at a time while relationship stamping is a single set-based query. Progress, counts, and any still-missing UUIDs are reported through the modulelogger(warnings on leftovers), and the Redis client is always closed in afinallyblock. Called by this module’smainviaasyncio.run; not imported elsewhere.
- migrate_kg_uuids.main()[source]
Parse CLI arguments and run the UUID backfill migration.
Command-line entry point for
python migrate_kg_uuids.py. Parses--redis-url(defaulting to$REDIS_URLorredis://localhost:6379/0), best-effort loads SSL/mTLS settings fromConfig.redis_ssl_kwargsso a TLS-protected Redis can be reached, and hands both tomigratethroughasyncio.run.Invoked only from this module’s
if __name__ == "__main__"guard; it has no in-repo callers. Logging is configured at import time at module scope.- Return type:
- Returns:
None.
- Raises:
SystemExit – Raised by
argparsewhen given invalid arguments.