[GH-ISSUE #1188] the cli can't generate drizzle schema with array type #8635

Closed
opened 2026-04-13 03:46:51 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @thatgurkangurk on GitHub (Jan 11, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1188

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Follow setup instructions
  2. Add a custom field with the "string[]" type (use the drizzle adapter)
  3. Run pnpx @better-auth/cli generate

Current vs. Expected behavior

Expected behaviour is that it successfully generates a schema.

Current behaviour:
⠋ preparing schema...file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:10 ,b=be(i);for(let g in c){let j=function(r,n){r=G(r);let E=n.type;return{string:{sqlite:text('${r}'),pg:text('${r}'),mysql:n.unique?varchar('${r}', { length: 255 }):n.references?varchar('${r}', { length: 36 }):text('${r}')},boolean:{sqlite:integer('${r}', { mode: 'boolean' }),pg:boolean('${r}'),mysql:boolean('${r}')},number:{sqlite:integer('${r}'),pg:integer('${r}'),mysql:int('${r}')},date:{sqlite:integer('${r}', { mode: 'timestamp' }),pg:timestamp('${r}'),mysql:timestamp('${r}')}}[E][m||"sqlite"]};var v=j;let u=s?${c[g].modelName}s:c[g].modelName,f=c[g].fields,S=m==="mysql"?'varchar("id", { length: 36 }).primaryKey()':'text("id").primaryKey()',M=`export const ${u} = ${m}Table("${G(u)}", {
^

TypeError: Cannot read properties of undefined (reading 'pg')
at j (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:10:521)
at file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:12:57
at Array.map ()
at U (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:12:23)
at Z (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:23:377)
at Command.qe (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:23:940)`

What version of Better Auth are you using?

1.1.11

Provide environment information

- OS [Ubuntu 22.04 (WSL, Windows 11)]
- Browser [Chrome 131]

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

Package

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "~/db";

export const auth = betterAuth({
    database: drizzleAdapter(db, {
        provider: "pg",
    }),
    user: {
        additionalFields: {
            arrayfield: {
                type: "string[]",
            },
        },
    },
});

Additional context

No response

Originally created by @thatgurkangurk on GitHub (Jan 11, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1188 ### Is this suited for github? - [X] Yes, this is suited for github ### To Reproduce 1. Follow setup instructions 2. Add a custom field with the "string[]" type (use the drizzle adapter) 3. Run pnpx @better-auth/cli generate ### Current vs. Expected behavior Expected behaviour is that it successfully generates a schema. Current behaviour: `⠋ preparing schema...file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:10 `,b=be(i);for(let g in c){let j=function(r,n){r=G(r);let E=n.type;return{string:{sqlite:`text('${r}')`,pg:`text('${r}')`,mysql:n.unique?`varchar('${r}', { length: 255 })`:n.references?`varchar('${r}', { length: 36 })`:`text('${r}')`},boolean:{sqlite:`integer('${r}', { mode: 'boolean' })`,pg:`boolean('${r}')`,mysql:`boolean('${r}')`},number:{sqlite:`integer('${r}')`,pg:`integer('${r}')`,mysql:`int('${r}')`},date:{sqlite:`integer('${r}', { mode: 'timestamp' })`,pg:`timestamp('${r}')`,mysql:`timestamp('${r}')`}}[E][m||"sqlite"]};var v=j;let u=s?`${c[g].modelName}s`:c[g].modelName,f=c[g].fields,S=m==="mysql"?'varchar("id", { length: 36 }).primaryKey()':'text("id").primaryKey()',M=`export const ${u} = ${m}Table("${G(u)}", { ^ TypeError: Cannot read properties of undefined (reading 'pg') at j (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:10:521) at file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:12:57 at Array.map (<anonymous>) at U (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:12:23) at Z (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:23:377) at Command.qe (file:///home/gurkan/.cache/pnpm/dlx/bd24f151f196db996fccc457df6fc5a2e243e48979d03b9321caff829cbe74d4/19456034784-d165/node_modules/.pnpm/@better-auth+cli@1.1.11_@babel+core@7.26.0_kysely@0.27.5/node_modules/@better-auth/cli/dist/index.mjs:23:940)` ### What version of Better Auth are you using? 1.1.11 ### Provide environment information ```bash - OS [Ubuntu 22.04 (WSL, Windows 11)] - Browser [Chrome 131] ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { db } from "~/db"; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", }), user: { additionalFields: { arrayfield: { type: "string[]", }, }, }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 03:46:51 -05:00
Author
Owner

@thatgurkangurk commented on GitHub (Jan 11, 2025):

If the additional field is not an array, it generates successfully though

<!-- gh-comment-id:2585469295 --> @thatgurkangurk commented on GitHub (Jan 11, 2025): If the additional field is not an array, it generates successfully though
Author
Owner

@dosubot[bot] commented on GitHub (Jun 12, 2025):

Hi, @thatgurkangurk. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • The issue involves a TypeError in the CLI tool from the better-auth package.
  • Error occurs when generating a drizzle schema with a custom field of type "string[]".
  • The schema generates successfully if the field is not an array, indicating the issue is specific to array types.
  • You provided steps to reproduce the issue and detailed the expected versus actual behavior.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here.
  • If no updates are provided, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:2967419157 --> @dosubot[bot] commented on GitHub (Jun 12, 2025): Hi, @thatgurkangurk. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - The issue involves a TypeError in the CLI tool from the better-auth package. - Error occurs when generating a drizzle schema with a custom field of type "string[]". - The schema generates successfully if the field is not an array, indicating the issue is specific to array types. - You provided steps to reproduce the issue and detailed the expected versus actual behavior. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here. - If no updates are provided, the issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8635