Disclosure: I build Schemity, a desktop ERD tool - this post is from our blog and uses it for the examples.
TL;DR: A PostgreSQL schema rarely runs on CockroachDB unchanged. CockroachDB v26.3 has no range types,
money,xmlorpoint, no C collation, noDEFERRABLEforeign keys, and no BRIN, SP-GiST orEXCLUDE. It also changes what it accepts:integerbecomes 64-bit, and a table created withserialgets 19-digit ids, past what JavaScript can hold exactly. Read the schema for these before moving any data.
CockroachDB accepts most of a PostgreSQL schema, refuses a specific list of types, indexes and constraints outright, and quietly changes two things it accepts: the size of integer and what serial means. The refusals are the easy part, because the statement fails and tells you. The quiet changes are the ones that reach production, such as an order id that a JavaScript client rounds to a different number.
Everything below ran in throwaway containers. The schema was created on PostgreSQL 18.3, dumped with pg_dump --schema-only, and each statement of the dump was run on CockroachDB v26.3.4. It is an ordinary schema: users with a serial key and a COLLATE "C" name, orders with an identity key and a deferred foreign key, an events table with jsonb, tsvector, a tstzrange and a point, and a BRIN index.
Which PostgreSQL features does CockroachDB refuse?
CockroachDB v26.3 refuses range types, a handful of PostgreSQL-only types, COLLATE "C", deferrable foreign keys, and every index method except btree, GIN, its vector indexes and GiST on a spatial column.
| In the PostgreSQL schema | CockroachDB v26.3.4 says |
|---|---|
tstzrange, daterange, int4range, numrange, multiranges |
type "tstzrange" does not exist |
money, xml, point
|
unimplemented: this syntax |
name text COLLATE "C" |
invalid locale C: language: tag is not well-formed |
ADD CONSTRAINT ... DEFERRABLE INITIALLY DEFERRED, as pg_dump writes it |
at or near "deferred": syntax error: unimplemented |
CREATE INDEX ... USING brin |
unimplemented: this syntax |
USING hash (col), USING spgist
|
unimplemented: this syntax |
USING gist on a text column |
no default operator class for access method "gin" |
EXCLUDE USING gist (room WITH =, during WITH &&) |
unimplemented: this syntax |
CREATE INDEX ... NULLS NOT DISTINCT |
syntax error |
One failed CREATE TABLE takes its whole table with it, so every index and foreign key on it fails next with relation "events" does not exist. Read the first error per table, not the last.
Some of these have a direct replacement. For COLLATE "C", drop the collation: CockroachDB's plain STRING already sorts by bytes, A, B, a, b, as C does, while a locale such as en-US sorts a, A, b, B and should be chosen only for that order. A deferred foreign key becomes a plain one, which means each statement must insert the parent row before its children. Others take a design change. A tstzrange column and the EXCLUDE constraint that stopped bookings from overlapping become two timestamp columns and a check your application runs. Overlapping periods are then no longer something the database prevents.
Once events lost its tstzrange and point, CockroachDB took the rest of it: jsonb with a GIN index and tsvector with a GIN index, along with timestamptz defaults, identity columns and UNIQUE constraints elsewhere.
What does CockroachDB change without an error?
Two things: integer columns become 64-bit, and serial stops being a sequence.
SHOW default_int_size on a fresh CockroachDB cluster returns 8, so the dump's id integer and user_id integer are both created as INT8. Nothing fails, and the two still match each other, but they no longer match the int4 your ORM, your other services and your PostgreSQL replica expect. SET default_int_size = 4; keeps integer as INT4, with one catch measured here: sent on its own before the CREATE TABLE, it worked; sent in the same batch as the CREATE TABLE, the column still came out bigint. A migration tool that sends a whole file as one query gets 64-bit integers anyway.
serial changes only where the DDL says serial. A pg_dump never does: it writes id integer, a CREATE SEQUENCE and a nextval default, and on CockroachDB those numbered the first rows 1 and 2. Hand-written DDL and migrations that say serial or bigserial are different. SHOW serial_normalization returns rowid, and the CockroachDB docs state that in that mode "SERIAL implies DEFAULT unique_rowid()", always as INT8:
CREATE TABLE users (id serial PRIMARY KEY, email text NOT NULL UNIQUE);
INSERT INTO users (email) VALUES ('a'), ('b') RETURNING id;
-- 1230620201065447425
-- 1230620201065545729
Those ids are larger than 9,007,199,254,740,991, the largest integer a JavaScript number holds exactly, so a browser or Node client that parses them as numbers rounds them. An API that returns id: 1230620201065447425 as JSON hands the frontend a different id than the one in the database. With SET serial_normalization = 'sql_sequence' first, a serial table numbered its rows 1 and 2 from a real sequence.
Serial, identity or UUID: which primary key should you use on CockroachDB?
Use a UUID key with gen_random_uuid() for new tables, and keep a sequence only where existing ids must survive the move.
CockroachDB printed the same NOTICE for the serial table, the identity table and the sequence-backed one: "using sequential values in a primary key does not perform as well as using random UUIDs." Its docs give the reason: a UUID key "more uniformly scatters" new rows "across all of a table's underlying key-value ranges", while sequential keys send every insert to the same range.
| Key | On CockroachDB | Use it when |
|---|---|---|
serial, default settings |
INT8 DEFAULT unique_rowid(), 19-digit ids |
Never by accident; only if every client reads ids as strings |
A sequence: the dump's nextval, or serial with sql_sequence
|
Ids from 1, with the NOTICE
|
You copy existing rows and their ids must not change |
GENERATED ALWAYS AS IDENTITY |
Sequential, with the NOTICE
|
The same as a sequence, written the standard way |
UUID DEFAULT gen_random_uuid() |
Random, spread over ranges | New tables, and tables nothing outside refers to by number |
The middle rows are the migration case. Order 10482 that customers see in emails has to stay 10482, so those tables keep a sequence, and the hotspot it causes is a cost you accept for compatibility. PostgreSQL itself has no ranges to spread writes over, so the same question there is decided on other grounds.
How do you find these in your own schema before migrating?
Dump the schema and read it against CockroachDB's rules, which takes one command and no CockroachDB cluster.
Schemity is database design software that reads your live database, shows the impact of every schema change before it runs, and keeps the diagram as a file in Git. To understand your schema before it moves, its schema lint has a set of CockroachDB rules, and the free Migration Check command line tool runs them on a dump with no database at all:
pg_dump --schema-only mydb > schema.sql
schemity lint --dialect cockroachdb --schema schema.sql
On the dump of the schema above it listed the refusals with the column or index each one is on, for example events.at CockroachDB has no TSTZRANGE type, so creating this column fails., users.name CockroachDB refuses collation "C" and orders_user_id_fkey is DEFERRABLE INITIALLY DEFERRED. It also reported the sequential primary keys on users, orders and events with CockroachDB's own recommendation, and orders_placed_at_idx, a btree index that leads with a DEFAULT now() timestamp. That index sends every new order to the same range, and CockroachDB's answer to it is a hash-sharded index, CREATE INDEX ON orders (placed_at) USING HASH, with USING HASH after the column list.
In the desktop app, CockroachDB is its own database type (a Schemity Pro feature). The type and index lists offer only what CockroachDB takes, the same lint runs in the lint drawer, and a migration it applies sends SET default_int_size = 4 as its own statement first, so an integer you designed stays 32-bit.
Writing this post found gaps in those rules, fixed for the next release: the range types were not on the refused list, a GiST index on a non-spatial column or an SP-GiST index was not reported, and the collation and hash-sharding advice now reads as above. One refusal is still not linted: an EXCLUDE constraint, which the diagram shows but the CockroachDB rules do not read yet.
Related reading
- Transactional DDL in PostgreSQL, MySQL and CockroachDB covers the other CockroachDB surprise: each schema change in a migration commits on its own.
-
Preventing overlapping date ranges with EXCLUDE or WITHOUT OVERLAPS shows what a range column and its
EXCLUDEconstraint do on PostgreSQL, which is what a CockroachDB move gives up. - UUID or bigint primary key in PostgreSQL weighs the same key choice on a database with no ranges to spread writes over.

Top comments (1)
Compatibility claims are safest when treated as a migration test rather than a syntax promise. I would run the real schema through a clean apply, then diff catalog metadata and execute representative writes, indexes, and constraints. The important failures are often semantic changes that compile successfully but alter defaults, locking, or transaction behavior.