[GH-ISSUE #3980] Force SQL file generation #18415

Closed
opened 2026-04-15 16:52:31 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @KristofKekesi on GitHub (Aug 13, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3980

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I want to remake migration files after I have made them with the command
npx @better-auth/cli@latest migrate or npx @better-auth/cli@latest generate
but I cannot remake this file since no changes are detected in the schema. I have dropped the Postgres database but the cli doesn't remake the SQL file to init the DB with.

Output:

2025-08-13T17:42:18.282Z WARN [Better Auth]: Social provider facebook is missing clientId or clientSecret
2025-08-13T17:42:18.284Z WARN [Better Auth]: Social provider google is missing clientId or clientSecret
2025-08-13T17:42:18.342Z INFO [Better Auth]: 🚀 No migrations needed.

Current vs. Expected behavior

I want to make this file since I have deleted the generated before. What commands should I use to force the sql output from scratch?

What version of Better Auth are you using?

1.3.6

System info

System:
    OS: macOS 15.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 78.44 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 139.0.7258.67
    Safari: 18.1

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { Pool } from "pg"; 
import { poolConfig } from "../server/db-config";
import { ac, admin, user } from "./permissions";
import { admin as adminPlugin } from "better-auth/plugins";

export const auth = betterAuth({
	database: new Pool(Object.assign(poolConfig, {
		user: process.env.DB_AUTH_USER,
		host: process.env.DB_AUTH_HOST,
		database: process.env.DB_AUTH_DATABASE,
		password: process.env.DB_AUTH_PASSWORD,
		port: parseInt(process.env.DB_AUTH_PORT ?? "5432", 10)
    })),
	emailAndPassword: {
		enabled: true,
	},
	socialProviders: {
		facebook: {
            clientId: process.env.FACEBOOK_CLIENT_ID as string,
            clientSecret: process.env.FACEBOOK_CLIENT_SECRET as string,
			scopes: ["email"]
        },
		google: {
			prompt: "select_account",
            clientId: process.env.GOOGLE_CLIENT_ID as string,
            clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
        },
	},
	plugins: [
		adminPlugin({
            ac,
            roles: { admin, user }
        }),
	]
});

Additional context

No response

Originally created by @KristofKekesi on GitHub (Aug 13, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3980 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I want to remake migration files after I have made them with the command `npx @better-auth/cli@latest migrate` or `npx @better-auth/cli@latest generate` but I cannot remake this file since no changes are detected in the schema. I have dropped the Postgres database but the cli doesn't remake the SQL file to init the DB with. Output: ``` 2025-08-13T17:42:18.282Z WARN [Better Auth]: Social provider facebook is missing clientId or clientSecret 2025-08-13T17:42:18.284Z WARN [Better Auth]: Social provider google is missing clientId or clientSecret 2025-08-13T17:42:18.342Z INFO [Better Auth]: 🚀 No migrations needed. ``` ### Current vs. Expected behavior I want to make this file since I have deleted the generated before. What commands should I use to force the sql output from scratch? ### What version of Better Auth are you using? 1.3.6 ### System info ```bash System: OS: macOS 15.1 CPU: (8) arm64 Apple M1 Pro Memory: 78.44 MB / 16.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 139.0.7258.67 Safari: 18.1 ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { Pool } from "pg"; import { poolConfig } from "../server/db-config"; import { ac, admin, user } from "./permissions"; import { admin as adminPlugin } from "better-auth/plugins"; export const auth = betterAuth({ database: new Pool(Object.assign(poolConfig, { user: process.env.DB_AUTH_USER, host: process.env.DB_AUTH_HOST, database: process.env.DB_AUTH_DATABASE, password: process.env.DB_AUTH_PASSWORD, port: parseInt(process.env.DB_AUTH_PORT ?? "5432", 10) })), emailAndPassword: { enabled: true, }, socialProviders: { facebook: { clientId: process.env.FACEBOOK_CLIENT_ID as string, clientSecret: process.env.FACEBOOK_CLIENT_SECRET as string, scopes: ["email"] }, google: { prompt: "select_account", clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, }, plugins: [ adminPlugin({ ac, roles: { admin, user } }), ] }); ``` ### Additional context _No response_
GiteaMirror added the lockedenhancement labels 2026-04-15 16:52:31 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 13, 2025):

Hi @KristofKekesi! I'm Dosu and I’m helping the better-auth team.

There isn’t a documented way to force SQL migration file generation in Better Auth CLI if no schema changes are detected—even after deleting previous migration files. The CLI checks the current schema against migration history, and if nothing has changed, it will output “No migrations needed” and skip file generation. There’s no --force flag or similar option for this scenario in v1.3.6, and deleting migration files alone won’t trigger regeneration because migration state is tracked elsewhere (often in the database or a metadata file) [docs].

Some users have reported that running migration commands repeatedly without schema changes results in empty migration files or no new migrations being generated [issue]. A maintainer once suggested a preview CLI package as a workaround, but this isn’t an official or general solution.

If you need to re-initialize your migrations from scratch, you’d typically need to reset both the migration tracking artifacts and the database itself, but this isn’t supported natively by the CLI. For now, the best practice is to avoid deleting migration files unless you’re also resetting the database to match.

Let me know if you want more details about manual workarounds or migration state!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3184903879 --> @dosubot[bot] commented on GitHub (Aug 13, 2025): <!-- Greeting --> Hi @KristofKekesi! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> There isn’t a documented way to force SQL migration file generation in Better Auth CLI if no schema changes are detected—even after deleting previous migration files. The CLI checks the current schema against migration history, and if nothing has changed, it will output “No migrations needed” and skip file generation. There’s no `--force` flag or similar option for this scenario in v1.3.6, and deleting migration files alone won’t trigger regeneration because migration state is tracked elsewhere (often in the database or a metadata file) [[docs](https://better-auth.com/docs/concepts/cli)]. Some users have reported that running migration commands repeatedly without schema changes results in empty migration files or no new migrations being generated [[issue](https://github.com/better-auth/better-auth/issues/2858)]. A maintainer once suggested a preview CLI package as a workaround, but this isn’t an official or general solution. If you need to re-initialize your migrations from scratch, you’d typically need to reset both the migration tracking artifacts and the database itself, but this isn’t supported natively by the CLI. For now, the best practice is to avoid deleting migration files unless you’re also resetting the database to match. Let me know if you want more details about manual workarounds or migration state! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/ed840003-aeb8-42d4-9145-78f801676f08?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/ed840003-aeb8-42d4-9145-78f801676f08?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/ed840003-aeb8-42d4-9145-78f801676f08?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/ed840003-aeb8-42d4-9145-78f801676f08?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ed840003-aeb8-42d4-9145-78f801676f08?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/ed840003-aeb8-42d4-9145-78f801676f08?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ed840003-aeb8-42d4-9145-78f801676f08?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3980)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18415