Skip to content

docs(database): describe auto-increment columns outside the primary key - #196

Open
roxblnfk wants to merge 1 commit into
2.xfrom
docs/175-non-pk-auto-increment
Open

roxblnfk wants to merge 1 commit into
2.xfrom
docs/175-non-pk-auto-increment

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Oct 5, 2026

Copy link
Copy Markdown
Member

Closes #175.

Primary-key auto-increment was already covered; this documents auto-incremented columns that are not the primary key.

  • database/declaration.md: a new "Auto-increment Columns Outside the Primary Key" section with per-driver behaviour — PostgreSQL serial() / bigSerial() / smallSerial() (Adding the ability to use serial without primary key database#106, 2.5.0); MySQL, where an autoIncrement: true column is always added to the primary key and the table is created only with the counter first in it; no support on SQLite and SQL Server.
  • annotated/entity.md: an entity example with a serial column and #[GeneratedValue(onInsert: true)], how the value is read back (RETURNING on PostgreSQL, not on MySQL), and what happens on other drivers.

Checked on PostgreSQL 17 and MySQL 8.0 (schema and ORM paths), SQLite, and the column DDL every driver renders, against cycle/database 2.x, cycle/orm 2.x and cycle/annotated 4.x.

Serial columns without a primary key (cycle/database#106, 2.5.0) were undocumented, and the per-driver behaviour differs a lot: only PostgreSQL has a real non-PK counter, MySQL folds an AUTO_INCREMENT column into the primary key, SQLite and SQL Server have no option for it (#175).

Assisted-By: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write about auto increment

1 participant