Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to declare IDENTITY columns? #380

Open
cakoose opened this issue Nov 10, 2021 · 2 comments
Open

How to declare IDENTITY columns? #380

cakoose opened this issue Nov 10, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@cakoose
Copy link
Collaborator

cakoose commented Nov 10, 2021

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('')
@cakoose cakoose added the bug Something isn't working label Nov 10, 2021
@martijndeh
Copy link
Contributor

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

@cakoose
Copy link
Collaborator Author

cakoose commented Nov 15, 2021

.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants