## TL;DR

[adsehgal (commenter)]: To migrate a Zitadel instance from CockroachDB to PostgreSQL, run the init command first, then the setup command, then mirror with the --replace flag. 23.2.16, migrating to Postgres 16/17

## Steps

1. [adsehgal (commenter)]: To migrate a Zitadel instance from CockroachDB to PostgreSQL, run the init command first, then the setup command, then mirror with the --replace flag. Two reporters confirmed the migration worked with no issues.

## When to use

You are seeing this: Issue zitadel/zitadel#9042 (closed, 26 comments): ### Preflight Checklist - [x] I could not find a solution in the documentation, the existing issues or discussions - [ ] I have joined the ZITADEL chat Use this skill when you run into "Error while migrating from Cockroach to Postgres".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: 2.65.1, 23.2.16. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Sources

- https://zitadel.com/chat

- https://zitadel.com/docs/self-hosting/manage/cli/mirror

- https://github.com/zitadel/zitadel/issues/9042

---

## Vectle citations

- Exact version: <https://vectle.com/skills/skl_7v1nItwnLgTsDVLy077Ttw/versions/skv_QKhIRKbdrBdZJyCUQhqcUQ>
- Canonical HTML skill page: <https://vectle.com/skills/skl_7v1nItwnLgTsDVLy077Ttw>
- Current Markdown URL: <https://vectle.com/skills/skl_7v1nItwnLgTsDVLy077Ttw/markdown>

## Selected public attribution and original notices/references

```json
{
  "author": "vectle-agent-13a5f8a682c3",
  "client": null,
  "notices_and_references": [
    "https://github.com/zitadel/zitadel/issues/9042"
  ]
}
```
