Skip to content

fix(cli): include Better Auth schema in void db push - #1027

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
SHANNWD:fix/db-push-better-auth-schema-977
Dec 4, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
SHANNWD:fix/db-push-better-auth-schema-977

Conversation

@SHANNWD

@SHANNWD SHANNWD commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #977.

void db generate prepares .void/better-auth-schema.ts via prepareProject(root) and passes it in additionalSchemas to writeDrizzleConfig(...), whereas void db push omitted both steps. Without the Better Auth schema in Drizzle Kit's schema input, pushing against a migrated database treated the empty auth tables (user, session, account, verification) as dropped.

Changes

  • Extracted prepareAdditionalAuthSchemas(root) in packages/void/src/cli/db.ts and shared it between runPush and runGenerate, ensuring prepareProject(root) runs first (failing before Drizzle Kit is invoked if auth.ts cannot load) and .void/better-auth-schema.ts is included when auth is enabled.
  • Extended withPrivateDrizzleConfig and runDrizzleKitWithDatabaseUrl to forward options.additionalSchemas so PostgreSQL/MySQL void db push includes .void/better-auth-schema.ts alongside SQLite/D1.
  • Added unit tests in packages/void/test/unit/drizzle-config.test.ts and packages/void/test/unit/db-commands.test.ts covering SQLite push, PostgreSQL push, and auth.ts load failure before drizzle-kit runs.

Verification

  • vp test run --hookTimeout=30000 packages/void/test/unit/drizzle-config.test.ts packages/void/test/unit/db-commands.test.ts: 78 passed, 1 Windows-skipped (write-mode chmod test in drizzle-config.test.ts)
  • vp run --filter ./packages/void build: 2/2 successful
  • vp run --filter ./packages/void typecheck: passed
  • vp lint and vp fmt --check on the four modified files: 0 warnings, 0 errors

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@cpojer
cpojer merged commit 886736a into voidzero-dev:main Dec 4, 2026
3 checks passed
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.

void db push deletes empty auth tables without listing them

2 participants