Inconsistent state when creating users in ZITADEL + local DB (NestJS + Drizzle ORM)
I’m facing an issue where a user is successfully created in ZITADEL, but the insert into my PostgreSQL database (via Drizzle ORM) fails.
This leaves me with a user that exists in ZITADEL but not in my local DB.
To handle this, I tried creating the user in my DB first with a status = "pending" (waiting for confirmation), then calling ZITADEL, and finally updating the status to "active".
However, if the status update fails, I end up with garbage data — the user exists in both systems but the local record stays stuck in "pending" state.
Wrapping both operations in a Drizzle transaction doesn’t help since ZITADEL is an external service.
Has anyone experienced this kind of inconsistency between ZITADEL and their own DB?
What’s the recommended way to handle this properly?
This leaves me with a user that exists in ZITADEL but not in my local DB.
To handle this, I tried creating the user in my DB first with a status = "pending" (waiting for confirmation), then calling ZITADEL, and finally updating the status to "active".
However, if the status update fails, I end up with garbage data — the user exists in both systems but the local record stays stuck in "pending" state.
Wrapping both operations in a Drizzle transaction doesn’t help since ZITADEL is an external service.
Has anyone experienced this kind of inconsistency between ZITADEL and their own DB?
What’s the recommended way to handle this properly?