mammoth
mammoth copied to clipboard
How to declare `IDENTITY` columns?
Postgres recommends using IDENTITY
(introduced in v10) instead of SERIAL
: https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_serial
How should I declare such a column in my Mammoth table schema? This is what I'm doing now:
id: int8().default('')
Identity [1] is not supported yet. As a workaround to get the typing right you can set a default or use .notNull()
.
Unfortunately there is not a workaround for the migration generation. This needs to support identity. I'm planning to find some time again the coming weeks to work on Mammoth. I'll add this to my list.
[1] https://www.postgresql.org/docs/13/sql-createtable.html
.notNull()
on its own didn't work because then the field is still required when calling .insertInto
. But .default('')
works fine for us, since we're not using Mammoth schema generation/migration.