[PR #7373] feat(cli): support forced schema file generation and migration #7268

Open
opened 2026-03-13 13:30:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7373
Author: @himself65
Created: 1/14/2026
Status: 🔄 Open

Base: canaryHead: himself65/2026/01/14/cli


📝 Commits (4)

  • cbbdd92 feat(cli): support forced schema file generation and migration
  • 324f341 fix(better-auth): use const instead of let for headers in test
  • 6f2b1ff chore: empty commit
  • 3345695 Merge branch 'canary' into himself65/2026/01/14/cli

📊 Changes

9 files changed (+383 additions, -19 deletions)

View changed files

📝 docs/content/docs/concepts/cli.mdx (+2 -0)
📝 packages/better-auth/src/db/get-migration.ts (+51 -3)
📝 packages/cli/src/commands/generate.ts (+7 -0)
📝 packages/cli/src/commands/migrate.ts (+10 -1)
📝 packages/cli/src/generators/index.ts (+2 -7)
📝 packages/cli/src/generators/kysely.ts (+24 -2)
📝 packages/cli/src/generators/types.ts (+12 -5)
📝 packages/cli/test/generate.test.ts (+77 -1)
📝 packages/cli/test/migrate.test.ts (+198 -0)

📄 Description

Summary by cubic

Adds a --force flag to CLI generate and migrate to rebuild schemas and run full destructive migrations by dropping and recreating Better Auth tables. Updates getMigrations, docs, and tests to support forced regeneration.

  • New Features

    • CLI: -f/--force on generate and migrate. For Kysely, generate emits DROP + CREATE; migrate drops then recreates tables.
    • Core: getMigrations(config, { force }) treats the DB as empty, drops tables in reverse order, and includes DROP statements in compileMigrations.
    • Docs/Tests: Added flag docs and comprehensive tests for forced generate/migrate flows.
  • Migration

    • Use with care. This deletes data in Better Auth tables.
    • Commands: npx @better-auth/cli migrate --force --yes and npx @better-auth/cli generate --force.

Written for commit 33456957a2. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7373 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/14/2026 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `himself65/2026/01/14/cli` --- ### 📝 Commits (4) - [`cbbdd92`](https://github.com/better-auth/better-auth/commit/cbbdd92be85145048d3ff0f286fcdb8da2515ca1) feat(cli): support forced schema file generation and migration - [`324f341`](https://github.com/better-auth/better-auth/commit/324f3414c7fea22a3e957ace71f448d4e618d911) fix(better-auth): use const instead of let for headers in test - [`6f2b1ff`](https://github.com/better-auth/better-auth/commit/6f2b1ff0fd4a53213af5f6f270cada6857df201c) chore: empty commit - [`3345695`](https://github.com/better-auth/better-auth/commit/33456957a209c0583c059b1fac1949de50555e9a) Merge branch 'canary' into himself65/2026/01/14/cli ### 📊 Changes **9 files changed** (+383 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/cli.mdx` (+2 -0) 📝 `packages/better-auth/src/db/get-migration.ts` (+51 -3) 📝 `packages/cli/src/commands/generate.ts` (+7 -0) 📝 `packages/cli/src/commands/migrate.ts` (+10 -1) 📝 `packages/cli/src/generators/index.ts` (+2 -7) 📝 `packages/cli/src/generators/kysely.ts` (+24 -2) 📝 `packages/cli/src/generators/types.ts` (+12 -5) 📝 `packages/cli/test/generate.test.ts` (+77 -1) 📝 `packages/cli/test/migrate.test.ts` (+198 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds a --force flag to CLI generate and migrate to rebuild schemas and run full destructive migrations by dropping and recreating Better Auth tables. Updates getMigrations, docs, and tests to support forced regeneration. - **New Features** - CLI: -f/--force on generate and migrate. For Kysely, generate emits DROP + CREATE; migrate drops then recreates tables. - Core: getMigrations(config, { force }) treats the DB as empty, drops tables in reverse order, and includes DROP statements in compileMigrations. - Docs/Tests: Added flag docs and comprehensive tests for forced generate/migrate flows. - **Migration** - Use with care. This deletes data in Better Auth tables. - Commands: npx @better-auth/cli migrate --force --yes and npx @better-auth/cli generate --force. <sup>Written for commit 33456957a209c0583c059b1fac1949de50555e9a. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:30:13 -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#7268