#!/usr/bin/env python
"""Write the stable key (0.4.0) onto every playbook step stored before keys existed — the key it is already read
with (the pack's designed key while it is still the pack's step, else a slug of its title), so ids derived from it
never change. Idempotent: a second run writes nothing. Run once per bucket after erp-migrate has added step_key.
BUCKET=<bucket> DODIL_ORG=<org> DODIL_SERVICE_ACCOUNT_ID=… DODIL_SERVICE_ACCOUNT_SECRET=… \\
python scripts/backfill_step_keys.py
"""
import pathlib
import sys
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / "src"))
def main() -> int:
from brick_hr.application import use_cases
with use_cases.repository() as uow:
n = uow.playbooks.backfill_keys()
print(f"step keys written: {n}")
return 0
if __name__ == "__main__":
raise SystemExit(main())