Skip to content

fix(db): make auth schema creation in migration 0013 idempotent - #7

Merged
lxup merged 1 commit into
mainfrom
fix/auth-schema-migration-idempotency
Oct 18, 2026
Merged

lxup merged 1 commit into
mainfrom
fix/auth-schema-migration-idempotency

Conversation

@lxup

@lxup lxup commented Oct 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Migration 0000 already creates the auth schema; 0013 (added when Drizzle became the sole owner of better-auth's tables) re-creates it unconditionally with a bare CREATE SCHEMA "auth";
  • On a full fresh-database replay (0000 through 0026, e.g. a brand new cluster/dev DB), this fails once it reaches 0013: schema "auth" already exists
  • Changed to CREATE SCHEMA IF NOT EXISTS "auth";

Test plan

  • Ran the complete migration chain (drizzle-kit migrate, 0000→0026) + the reference-data seed against a fresh, empty postgres+postgis container built from apps/postgres/Dockerfile - all 27 migrations apply and seeding completes successfully

0000 already creates the "auth" schema; 0013 (added later to make
Drizzle the sole owner of better-auth's tables) re-created it
unconditionally, so a full migration replay on a fresh database fails
with "schema auth already exists" once it reaches 0013. Verified by
running the complete 0000-0026 chain + seed against a throwaway
postgres+postgis container.
@lxup
lxup merged commit 23729ee into main Oct 18, 2026
1 of 2 checks passed
@lxup
lxup deleted the fix/auth-schema-migration-idempotency branch October 25, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant