[PR #5943] fix: use identity instead of serial for pg schema #14585

Closed
opened 2026-04-13 09:32:08 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5943

State: closed
Merged: Yes


closes: https://github.com/better-auth/better-auth/issues/5549
linear: https://linear.app/better-auth/issue/ENG-661/fix-use-identity-over-serial-for-pg-number-ids

Converts pg with generateId === 'serial' to use integer with IDENTITY instead of serial


Summary by cubic

Switches Postgres numeric IDs from serial to identity across migrations and CLI schema generation, aligning with modern PG behavior and fixing #5549 and ENG-661. Generated SQL now uses integer GENERATED BY DEFAULT AS IDENTITY.

  • Bug Fixes
    • Migration generator: use sqlinteger GENERATED BY DEFAULT AS IDENTITY for Postgres when number IDs are enabled; adjust column builder to avoid double identity config.
    • CLI (Drizzle): replace serial("id") with integer("id").generatedByDefaultAsIdentity().primaryKey(); remove serial import.
    • Tests: add Postgres identity test and update snapshots to ensure no SERIAL appears.

Written for commit 45beb7a137. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5943 **State:** closed **Merged:** Yes --- closes: https://github.com/better-auth/better-auth/issues/5549 linear: https://linear.app/better-auth/issue/ENG-661/fix-use-identity-over-serial-for-pg-number-ids Converts `pg` with `generateId === 'serial'` to use integer with `IDENTITY` instead of `serial` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Switches Postgres numeric IDs from serial to identity across migrations and CLI schema generation, aligning with modern PG behavior and fixing #5549 and ENG-661. Generated SQL now uses integer GENERATED BY DEFAULT AS IDENTITY. - **Bug Fixes** - Migration generator: use sql`integer GENERATED BY DEFAULT AS IDENTITY` for Postgres when number IDs are enabled; adjust column builder to avoid double identity config. - CLI (Drizzle): replace serial("id") with integer("id").generatedByDefaultAsIdentity().primaryKey(); remove serial import. - Tests: add Postgres identity test and update snapshots to ensure no SERIAL appears. <sup>Written for commit 45beb7a1373ec7e74915cdcdbad775f050948e4f. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:32:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14585