[GH-ISSUE #799] Column name in snake_case #8441

Closed
opened 2026-04-13 03:30:42 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @emersonlaurentino on GitHub (Dec 7, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/799

Just like usePlural, would be nice if the database drizzleAdapter config has an useSnakeCase to generate the column names in snake_case.

Example:

betterAuth({
  database: drizzleAdapter(db, {
    provider: "sqlite",
    usePlural: true,
    useSnakeCase: true,
  }),
});

the schema is like that:

// ...
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
// ...
Originally created by @emersonlaurentino on GitHub (Dec 7, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/799 Just like `usePlural`, would be nice if the database drizzleAdapter config has an `useSnakeCase` to generate the column names in snake_case. Example: ```tsx betterAuth({ database: drizzleAdapter(db, { provider: "sqlite", usePlural: true, useSnakeCase: true, }), }); ``` the schema is like that: ```tsx // ... expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(), // ... ```
GiteaMirror added the lockedduplicate labels 2026-04-13 03:30:42 -05:00
Author
Owner

@Bekacru commented on GitHub (Dec 7, 2024):

for drizzle, prisma... snake case should be handled by the adapter instead. Better Auth only interacts with the orm layer. meaning in your case it only cares what you named your keys not the actual mapping in your db.

<!-- gh-comment-id:2524953721 --> @Bekacru commented on GitHub (Dec 7, 2024): for drizzle, prisma... snake case should be handled by the adapter instead. Better Auth only interacts with the orm layer. meaning in your case it only cares what you named your keys not the actual mapping in your db.
Author
Owner

@Bekacru commented on GitHub (Dec 7, 2024):

we plan to support it for the builtin Kysely adapter but there is open issue at #410 already

<!-- gh-comment-id:2524954131 --> @Bekacru commented on GitHub (Dec 7, 2024): we plan to support it for the builtin Kysely adapter but there is open issue at #410 already
Author
Owner

@emersonlaurentino commented on GitHub (Dec 7, 2024):

for drizzle, prisma... snake case should be handled by the adapter instead. Better Auth only interacts with the orm layer. meaning in your case it only cares what you named your keys not the actual mapping in your db.

but when I run the migrate command by CLI, the map is in camelCase, that's my point.

<!-- gh-comment-id:2525100767 --> @emersonlaurentino commented on GitHub (Dec 7, 2024): > for drizzle, prisma... snake case should be handled by the adapter instead. Better Auth only interacts with the orm layer. meaning in your case it only cares what you named your keys not the actual mapping in your db. but when I run the migrate command by CLI, the map is in camelCase, that's my point.
Author
Owner

@svaraborut commented on GitHub (Dec 15, 2024):

Yes, the migrate command is used for the builtin Kysely which as mentioned by @Bekacru does not yet support snake_case and is tracked separately in https://github.com/better-auth/better-auth/issues/410 . Other adapters have their respective configuration for casing.

<!-- gh-comment-id:2543516106 --> @svaraborut commented on GitHub (Dec 15, 2024): Yes, the `migrate` command is used for the builtin Kysely which as mentioned by @Bekacru does not yet support snake_case and is tracked separately in https://github.com/better-auth/better-auth/issues/410 . Other adapters have their respective configuration for casing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8441