feat: Use IDENTITY column for int primary keys instead of BIGSERIAL#293
Merged
Conversation
`BIGSERIAL` is not recommended. See: https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_serial The recommendation is instead to use `IDENTITY` columns. This PR updates the create `user` table migration (just the one using bigint as the primary key) to create the pk as an IDENTITY column instead of a BIGSERIAL. This PR also adds the `pk_bigint_identity` method to enable creating an IDENTITY pk in any table. The `pk_bigint_identity_options` method is added as well, which is the same except it allows configuring the sequence for the identity generation. See: https://www.postgresql.org/docs/current/sql-createsequence.html Closes #290
Codecov ReportAll modified and coverable lines are covered by tests ✅
Continue to review full report in Codecov by Sentry.
|
Merged
spencewenski
pushed a commit
that referenced
this pull request
Jul 25, 2024
## 🤖 New release * `roadster`: 0.5.9 -> 0.5.10 <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.5.10](roadster-v0.5.9...roadster-v0.5.10) - 2024-07-25 ### Added - Use IDENTITY column for int primary keys instead of BIGSERIAL ([#293](#293)) ### Fixed - Add "if exists" to user's drop_table migration statement ([#292](#292)) ### Other - Add tests for schema and check helper methods ([#289](#289)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BIGSERIALis not recommended. See: https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_serial. The recommendation is instead to useIDENTITYcolumns.This PR updates the create
usertable migration (just the one using bigint as the primary key) to create the pk as an IDENTITY column instead of a BIGSERIAL. This PR also adds thepk_bigint_identitymethod to enable creating an IDENTITY pk in any table. Thepk_bigint_identity_optionsmethod is added as well, which is the same except it allows configuring the sequence for the identity generation. See: https://www.postgresql.org/docs/current/sql-createsequence.htmlCloses #290