[GH-ISSUE #7611] CLI generate does not include admin plugin fields #28175

Closed
opened 2026-04-17 19:35:27 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @elithrar on GitHub (Jan 25, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7611

@better-auth/cli generate does not output admin plugin schema fields, even when the plugin is configured.

// better-auth.config.ts
import { betterAuth } from "better-auth";
import { admin } from "better-auth/plugins";

export const auth = betterAuth({
  plugins: [admin()],
  // ...
});
bunx @better-auth/cli generate --config ./better-auth.config.ts --output ./schema.ts

Expected: Generated schema includes role, banned, banReason, banExpires on user table and impersonatedBy on session table.

Actual: None of these fields are generated. Must add manually per the "Schema" section in the docs.

The admin plugin docs say:

Run the migration or generate the schema to add the necessary fields

But migrate doesn't work with Drizzle:

The migrate command only works with the built-in Kysely adapter.
For Drizzle, run `npx @better-auth/cli generate` to create the schema...

So Drizzle users have no CLI path to get admin fields—only manual addition.

  • better-auth: 1.4.17
  • @better-auth/cli: latest

Is this a documentation oversight or a bug with generate?

Originally created by @elithrar on GitHub (Jan 25, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7611 `@better-auth/cli generate` does not output admin plugin schema fields, even when the plugin is configured. ```ts // better-auth.config.ts import { betterAuth } from "better-auth"; import { admin } from "better-auth/plugins"; export const auth = betterAuth({ plugins: [admin()], // ... }); ``` ```sh bunx @better-auth/cli generate --config ./better-auth.config.ts --output ./schema.ts ``` Expected: Generated schema includes `role`, `banned`, `banReason`, `banExpires` on user table and `impersonatedBy` on session table. Actual: None of these fields are generated. Must add manually per the "Schema" section in the docs. The admin plugin docs say: > Run the migration or generate the schema to add the necessary fields But `migrate` doesn't work with Drizzle: ``` The migrate command only works with the built-in Kysely adapter. For Drizzle, run `npx @better-auth/cli generate` to create the schema... ``` So Drizzle users have no CLI path to get admin fields—only manual addition. - better-auth: 1.4.17 - @better-auth/cli: latest Is this a documentation oversight or a bug with `generate`?
GiteaMirror added the lockedbug labels 2026-04-17 19:35:27 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 25, 2026):

It looks like there’s an open issue regarding the @better-auth/cli generate command not including the admin plugin fields in the schema when using Drizzle. Users have noted that despite having the admin plugin configured, fields like role, banned, banReason, banExpires, and impersonatedBy are not generated automatically, requiring manual additions instead.

The current workaround involves running the generate command, but Drizzle users seem to lack a seamless CLI path for obtaining those fields [1] [6]. It's also noted that the migration command only works with the built-in Kysely adapter, which further complicates matters for Drizzle users [6].

If you haven't done so already, you can bring this issue up with the Better Auth team—tagging @bekacru or @ping__ might help in providing more targeted support!

Do you have any additional questions or need clarification on this issue?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3797389011 --> @better-auth-agent[bot] commented on GitHub (Jan 25, 2026): It looks like there’s an open issue regarding the `@better-auth/cli generate` command not including the admin plugin fields in the schema when using Drizzle. Users have noted that despite having the admin plugin configured, fields like `role`, `banned`, `banReason`, `banExpires`, and `impersonatedBy` are not generated automatically, requiring manual additions instead. The current workaround involves running the `generate` command, but Drizzle users seem to lack a seamless CLI path for obtaining those fields [[1]](https://github.com/better-auth/better-auth/issues/6606) [[6]](https://www.better-auth.com/docs/concepts/database). It's also noted that the migration command only works with the built-in Kysely adapter, which further complicates matters for Drizzle users [[6]](https://www.better-auth.com/docs/concepts/database). If you haven't done so already, you can bring this issue up with the Better Auth team—tagging @bekacru or @ping__ might help in providing more targeted support! Do you have any additional questions or need clarification on this issue? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@dosubot[bot] commented on GitHub (Jan 25, 2026):

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

This is a known limitation: for Drizzle users, @better-auth/cli generate does not automatically include admin plugin fields (role, banned, banReason, banExpires, impersonatedBy) in the generated schema, even when the admin plugin is configured. The CLI only outputs the core Better Auth fields and does not merge or preserve plugin fields unless they are already present in the schema at generation time. There is no CLI option or config workaround for this as of v1.4.17—the only solution is to manually add the required admin fields to your Drizzle schema after running the generate command. This limitation is documented in several issues and discussions, and there is no planned fix or extension point at this time. For more details, see issue #5874 and issue #4795.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3797393089 --> @dosubot[bot] commented on GitHub (Jan 25, 2026): <!-- Greeting --> Hi @elithrar! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a known limitation: for Drizzle users, `@better-auth/cli generate` does not automatically include admin plugin fields (`role`, `banned`, `banReason`, `banExpires`, `impersonatedBy`) in the generated schema, even when the admin plugin is configured. The CLI only outputs the core Better Auth fields and does not merge or preserve plugin fields unless they are already present in the schema at generation time. There is no CLI option or config workaround for this as of v1.4.17—the only solution is to manually add the required admin fields to your Drizzle schema after running the generate command. This limitation is documented in several issues and discussions, and there is no planned fix or extension point at this time. For more details, see [issue #5874](https://github.com/better-auth/better-auth/issues/5874) and [issue #4795](https://github.com/better-auth/better-auth/issues/4795). <!-- 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/34084f35-7ced-4ce9-9ed7-66757abc258b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/34084f35-7ced-4ce9-9ed7-66757abc258b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/34084f35-7ced-4ce9-9ed7-66757abc258b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/34084f35-7ced-4ce9-9ed7-66757abc258b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/34084f35-7ced-4ce9-9ed7-66757abc258b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/34084f35-7ced-4ce9-9ed7-66757abc258b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/34084f35-7ced-4ce9-9ed7-66757abc258b?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20limitation%3A%20for%20Drizzle%20users%2C%20%60%40better-auth/cli%20generate%60%20does%20not%20automatically%20include%20admin%20plugin%20fields%20%28%60role%60%2C%20%60banned%60%2C%20%60banReason%60%2C%20%60banExpires%60%2C%20%60impersonatedBy%60%29%20in%20the%20generated%20schema%2C%20even%20when%20the%20admin%20plugin%20is%20configured.%20The%20CLI%20only%20outputs%20the%20core%20Better%20Auth%20fields%20and%20does%20not%20merge%20or%20preserve%20plugin%20fields%20unless%20they%20are%20already%20present%20in%20the%20schema%20at%20generation%20time.%20There%20is%20no%20CLI%20option%20or%20config%20workaround%20for%20this%20as%20of%20v1.4.17%E2%80%94the%20only%20solution%20is%20to%20manually%20add%20the%20required%20admin%20fields%20to%20your%20Drizzle%20schema%20after%20running%20the%20generate%20command.%20This%20limitation%20is%20documented%20in%20several%20issues%20and%20discussions%2C%20and%20there%20is%20no%20planned%20fix%20or%20extension%20point%20at%20this%20time.%20For%20more%20details%2C%20see%20%5Bissue%20%235874%5D%28https%3A//github.com/better-auth/better-auth/issues/5874%29%20and%20%5Bissue%20%234795%5D%28https%3A//github.com/better-auth/better-auth/issues/4795%29.)&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/7611)
Author
Owner

@bytaesu commented on GitHub (Jan 26, 2026):

https://github.com/user-attachments/assets/2620869d-d791-4865-94a2-24a442e20992

Hi @elithrar,

This issue isn't reproducible on my end. Could you check based on the documentation?

  1. @better-auth/cli generate
  2. drizzle-kit generate
  3. drizzle-kit migrate

If this issue persists, feel free to mention me! 🙂

<!-- gh-comment-id:3801136357 --> @bytaesu commented on GitHub (Jan 26, 2026): https://github.com/user-attachments/assets/2620869d-d791-4865-94a2-24a442e20992 Hi @elithrar, This issue isn't reproducible on my end. Could you check based on the [documentation](https://www.better-auth.com/docs/adapters/drizzle)? 1. @better-auth/cli generate 2. drizzle-kit generate 3. drizzle-kit migrate If this issue persists, feel free to mention me! 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28175