Running CockroachDB in Docker with prorm
Read this page in the documentation
Running CockroachDB in Docker with prorm CockroachDB speaks the PostgreSQL wire protocol, so prorm talks to it through a dedicated cockroachdb dialect that reuses most of the PostgreSQL SQL generation while accounting for the differences (no SERIAL semantics you should rely on, different ALTER support, retryable transaction errors). Start the container A single-node insecure instance is enough for development and tests: Port 26257 is SQL; 8080 serves the admin UI at <http://localhost:8080>. The repository's compose file provides the same service: Waiting for readiness Create a database Unlike the PostgreSQL image there is no POSTGRESDB equivalent, so create the database yourself: Connect prorm to it A worked example Prefer UUID primary keys over a monotonic integer. CockroachDB distributes by key range, so sequential keys concentrate writes on one range — a hotspot that does not show up on a single node but does in a real cluster. Retryable transactions CockroachDB uses serializable isolation and will abort a transaction that conflicts, expecting the client to retry. Handle the retry error rather than treating it as fatal: See Transactions. Tear down Troubleshooting Symptom | Cause | --- | --- | database "ormtest" does not exist | The image creates no database. Run the CREATE DATABASE above. | Node exits immediately | start-single-node needs --insecure (or certificates). Check docker logs orm-cockroach. | restart transaction errors | Expected under contention — retry the transaction. | Schema change hangs | Cockroach runs schema changes asynchronously; sync({ alter: true }) can outpace them. Give the statement time or serialise migrations. | Related reading CockroachDB dialect Transactions