Use IDENTITY columns in PG10+
See original GitHub issueProblem
When I define a new entity/table in my schema using id Int @id @default(autoincrement())
the generator returns "id" SERIAL
.
Suggested solution
The recommended solution is to use the SQL standard GENERATED BY DEFAULT AS IDENTITY
.
Additional context
https://wiki.postgresql.org/wiki/Don’t_Do_This#Don.27t_use_serial
Nice to have
A way to migrate from SERIAL
to IDENTITY
columns.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:21
- Comments:6 (1 by maintainers)
Top Results From Across the Web
PostgreSQL 10 identity columns explained - EDB
Dropping the identity property of an existing column is easy: ALTER TABLE test_new ALTER COLUMN id DROP IDENTITY; You cannot accidentally make ...
Read more >What are Identity Columns?
An identity column has a start value, an increment, a maximum value, a minimum value, and a cycle option. ... ... The definition...
Read more >Waiting for PostgreSQL 10 – Identity columns - Depesz
Identity columns This is the SQL standard-conforming variant of PostgreSQL's serial columns. It fixes a few usability issues that serial ...
Read more >How to obtain last inserted Identity value with PG10 ... - GitHub
Hi, PG10 introduces identity fields, all great, except... how to obtain the inserted value in the row? The examples I've seen: INSERT INTO ......
Read more >PostgreSQL Identity Column
PostgreSQL allows you a table to have more than one identity column. Like the SERIAL , the GENERATED AS IDENTITY constraint also uses...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, that is what this feature request is about.
Any update on this? It would be nice to use best practices for auto incrementing fields in Postgres.