SwapSQL

MySQL → PostgreSQL

Convert MySQL AUTO_INCREMENT to PostgreSQL sequences

PostgreSQL implements auto-numbering with sequences (or the newer identity columns). A correct migration also restarts the counter above your existing ids.

AUTO_INCREMENT sequence / identity

What to know

Before / after

MySQL

CREATE TABLE users (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
);

PostgreSQL

CREATE TABLE users (
  id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
);
-- INSERT … RETURNING id;

Don't convert column-by-column — convert the whole database.

Upload a dump, get back ready-to-import SQL with this mapping (and every other one) applied.

Open the MySQL → PostgreSQL converter

See the full type mapping table or all guides.