sea-query
sea-query copied to clipboard
Stop using deprecated serial column type
Motivation
The generated PostgreSQL tables use serial/bigserial which appears to be obsolete for a long time.
- https://stackoverflow.com/questions/55300370/postgresql-serial-vs-identity
- https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_serial
Proposed Solutions
Use integer/bigint with the identity modifier as suggested?
Additional Information
Code ref: https://github.com/SeaQL/sea-query/blob/8ce9930b075aaa204a1b2adf08b234240e66fb57/src/backend/postgres/table.rs#L225
Just for reference for anyone who is not sure about how to achieve
create table posts (
id bigint primary key generated always as identity
)
the following can be used
Table::create()
.table(Post::Table)
.col(
big_integer(Post::Id)
.primary_key()
.extra("GENERATED ALWAYS AS IDENTITY")