[GH-ISSUE #6779] string[] type in user.additionalFields is broken with Drizzle ORM + pg after 1.4.x update #27950

Closed
opened 2026-04-17 19:14:13 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @anthonyma94 on GitHub (Dec 15, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6779

Originally assigned to: @ping-maxwell, @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Use this auth option and drizzle pg table
betterAuth({
    user: {
        additionalFields: {
            customPermissions: {
                type: "string[]",
                required: false,
                defaultValue: [],
                input: false,
            },
        },
    },
	database: drizzleAdapter(db, {
		provider: "pg",
	}),
});

export const betterAuthUserTable = pgTable("user", {
    id: text("id").primaryKey(),
    name: text("name").notNull(),
    email: text("email").notNull().unique(),
    emailVerified: boolean("email_verified").default(false).notNull(),
    image: text("image"),
    customPermissions: text("custom_permissions")
        .array()
        .notNull()
        .default(sql`'{}'`),
    createdAt: timestamp("created_at")
        .default(sql`now()`)
        .notNull(),
    updatedAt: timestamp("updated_at")
        .default(sql`now()`)
        .$onUpdate(() => new Date())
        .notNull(),
});

Current vs. Expected behavior

Pre 1.4.x update, a string[] type defaulted to a string array in pg. After 1.4.x, I suspect it uses JSON based on this PR. Since Drizzle has native support for string arrays (and would expect the custom field as a string array type), it errors out when referencing it.

Error:

TypeError: value.map is not a function
	at _PgArray.mapToDriverValue (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/pg-core/columns/common.ts:343:19)
	at <anonymous> (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:238:69)
	at Array.map (<anonymous>)
	at _SQL.buildQueryFromSourceParams (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:163:30)
	at <anonymous> (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:185:17)
	at Array.map (<anonymous>)
	at _SQL.buildQueryFromSourceParams (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:163:30)
	at <anonymous> (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:189:17)
	at Array.map (<anonymous>)
	at _SQL.buildQueryFromSourceParams (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:163:30)

What version of Better Auth are you using?

1.4.7

System info

{
  "system": {
    "platform": "linux",
    "arch": "x64",
    "version": "#88-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 09:28:41 UTC 2025",
    "release": "6.8.0-87-generic",
    "cpuCount": 16,
    "cpuModel": "AMD Ryzen 7 5800X 8-Core Processor",
    "totalMemory": "31.34 GB",
    "freeMemory": "22.25 GB"
  },
  "node": {
    "version": "v22.16.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.4.1"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.1.0"
    },
    {
      "name": "hono",
      "version": "^4.9.10"
    }
  ],
  "databases": [
    {
      "name": "drizzle",
      "version": "~0.44.2"
    },
    {
      "name": "@neondatabase/serverless",
      "version": "1.0.2"
    }
  ],
  "betterAuth": {
    "version": "^1.4.7",
    "config": null
  }
}

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
betterAuth({
    user: {
        additionalFields: {
            customPermissions: {
                type: "string[]",
                required: false,
                defaultValue: [],
                input: false,
            },
        },
    },
	database: drizzleAdapter(db, {
		provider: "pg",
	}),
});

Additional context

No response

Originally created by @anthonyma94 on GitHub (Dec 15, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6779 Originally assigned to: @ping-maxwell, @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Use this auth option and drizzle pg table ```ts betterAuth({ user: { additionalFields: { customPermissions: { type: "string[]", required: false, defaultValue: [], input: false, }, }, }, database: drizzleAdapter(db, { provider: "pg", }), }); export const betterAuthUserTable = pgTable("user", { id: text("id").primaryKey(), name: text("name").notNull(), email: text("email").notNull().unique(), emailVerified: boolean("email_verified").default(false).notNull(), image: text("image"), customPermissions: text("custom_permissions") .array() .notNull() .default(sql`'{}'`), createdAt: timestamp("created_at") .default(sql`now()`) .notNull(), updatedAt: timestamp("updated_at") .default(sql`now()`) .$onUpdate(() => new Date()) .notNull(), }); ``` ### Current vs. Expected behavior Pre 1.4.x update, a `string[]` type defaulted to a string array in pg. After 1.4.x, I suspect it uses JSON based on [this PR](#6581). Since Drizzle has native support for string arrays (and would expect the custom field as a string array type), it errors out when referencing it. Error: ``` TypeError: value.map is not a function at _PgArray.mapToDriverValue (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/pg-core/columns/common.ts:343:19) at <anonymous> (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:238:69) at Array.map (<anonymous>) at _SQL.buildQueryFromSourceParams (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:163:30) at <anonymous> (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:185:17) at Array.map (<anonymous>) at _SQL.buildQueryFromSourceParams (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:163:30) at <anonymous> (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:189:17) at Array.map (<anonymous>) at _SQL.buildQueryFromSourceParams (/workspaces/dmca-aws/node_modules/.pnpm/drizzle-orm@0.44.7_@neondatabase+serverless@1.0.2_@opentelemetry+api@1.9.0_@types+pg@8.15.6_kysely@0.28.8/node_modules/src/sql/sql.ts:163:30) ``` ### What version of Better Auth are you using? 1.4.7 ### System info ```bash { "system": { "platform": "linux", "arch": "x64", "version": "#88-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 09:28:41 UTC 2025", "release": "6.8.0-87-generic", "cpuCount": 16, "cpuModel": "AMD Ryzen 7 5800X 8-Core Processor", "totalMemory": "31.34 GB", "freeMemory": "22.25 GB" }, "node": { "version": "v22.16.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.4.1" }, "frameworks": [ { "name": "react", "version": "19.1.0" }, { "name": "hono", "version": "^4.9.10" } ], "databases": [ { "name": "drizzle", "version": "~0.44.2" }, { "name": "@neondatabase/serverless", "version": "1.0.2" } ], "betterAuth": { "version": "^1.4.7", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" betterAuth({ user: { additionalFields: { customPermissions: { type: "string[]", required: false, defaultValue: [], input: false, }, }, }, database: drizzleAdapter(db, { provider: "pg", }), }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-17 19:14:13 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 15, 2025):

Hi there! It looks like the recent update (starting in 1.4.x) appears to have changed how the string[] additional field is handled with Drizzle ORM using PostgreSQL. Previously, an empty array was correctly passed as a native string array, but now the default (often produced via the SQL fragment) may be interpreted as JSON or another type, which causes the error “value.map is not a function” when Drizzle expects an actual array [1].

A couple of next steps you might consider:

• Verify that the default value for your custom field is set to a native JavaScript array rather than a SQL string. For example, try setting the default directly using an empty array ([]) in your Better Auth configuration and update your Drizzle table schema accordingly.

• If Drizzle still interprets the value incorrectly, you might need to implement a conversion function or cast—ensuring that the incoming value is always cast to an array. This could mean checking any changes introduced in the 1.4.x release regarding field type serialization.

• As this appears to be a breaking change from the update (potentially linked to internal changes as noted in recent PR discussions), consider reaching out with detailed reproduction steps to our team members for further support.

Does this troubleshooting approach make sense in your scenario? tag @better-auth-agent if you would like an answer from the Agent.

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

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3656307346 --> @better-auth-agent[bot] commented on GitHub (Dec 15, 2025): Hi there! It looks like the recent update (starting in 1.4.x) appears to have changed how the string[] additional field is handled with Drizzle ORM using PostgreSQL. Previously, an empty array was correctly passed as a native string array, but now the default (often produced via the SQL fragment) may be interpreted as JSON or another type, which causes the error “value.map is not a function” when Drizzle expects an actual array [[1]](https://github.com/better-auth/better-auth/issues/1183). A couple of next steps you might consider: • Verify that the default value for your custom field is set to a native JavaScript array rather than a SQL string. For example, try setting the default directly using an empty array ([]) in your Better Auth configuration and update your Drizzle table schema accordingly. • If Drizzle still interprets the value incorrectly, you might need to implement a conversion function or cast—ensuring that the incoming value is always cast to an array. This could mean checking any changes introduced in the 1.4.x release regarding field type serialization. • As this appears to be a breaking change from the update (potentially linked to internal changes as noted in recent PR discussions), consider reaching out with detailed reproduction steps to our team members for further support. Does this troubleshooting approach make sense in your scenario? tag @better-auth-agent if you would like an answer from the Agent. _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/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 15, 2025):

This issue is caused by a breaking change in Better Auth ≥1.4.x: string[] fields in user.additionalFields are now stored as jsonb columns in PostgreSQL, not as native Postgres arrays. Drizzle ORM expects a native array (e.g., text().array()), so when it receives a JSONB value, it throws a TypeError: value.map is not a function because it's trying to treat a JSON object as an array. The migration logic in Better Auth is responsible for this mapping (source).

Meanwhile, the Drizzle schema generator in Better Auth still emits native array columns for string[] (source), which creates a mismatch between the generated schema and the actual database column type.

Workaround:
To resolve this, you can either:

  • Change your Drizzle schema to use .jsonb() for the affected field, so it matches the actual column type.
  • Or, if you need native arrays, you would need to manually adjust the migration/schema logic in Better Auth to restore the previous behavior (mapping string[] to native arrays), but there is currently no config option to do this.

If you need to migrate existing data, make sure to convert any array columns to JSONB before upgrading.

Let me know if you need a code snippet for the workaround or have questions about migration steps.

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:3656323266 --> @dosubot[bot] commented on GitHub (Dec 15, 2025): <!-- Answer --> This issue is caused by a breaking change in Better Auth ≥1.4.x: `string[]` fields in `user.additionalFields` are now stored as `jsonb` columns in PostgreSQL, not as native Postgres arrays. Drizzle ORM expects a native array (e.g., `text().array()`), so when it receives a JSONB value, it throws a `TypeError: value.map is not a function` because it's trying to treat a JSON object as an array. The migration logic in Better Auth is responsible for this mapping ([source](https://github.com/better-auth/better-auth/blob/a63e70ea27e2e936ae9915171c0e59054dc9b4a0/packages/better-auth/src/db/get-migration.ts#L281-L395)). Meanwhile, the Drizzle schema generator in Better Auth still emits native array columns for `string[]` ([source](https://github.com/better-auth/better-auth/blob/a63e70ea27e2e936ae9915171c0e59054dc9b4a0/packages/cli/src/generators/drizzle.ts#L20-L529)), which creates a mismatch between the generated schema and the actual database column type. **Workaround:** To resolve this, you can either: - Change your Drizzle schema to use `.jsonb()` for the affected field, so it matches the actual column type. - Or, if you need native arrays, you would need to manually adjust the migration/schema logic in Better Auth to restore the previous behavior (mapping `string[]` to native arrays), but there is currently no config option to do this. If you need to migrate existing data, make sure to convert any array columns to JSONB before upgrading. Let me know if you need a code snippet for the workaround or have questions about migration steps. <!-- 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/eb8371d6-a6d0-4a2e-96c0-32726491b260?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/eb8371d6-a6d0-4a2e-96c0-32726491b260?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/eb8371d6-a6d0-4a2e-96c0-32726491b260?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/eb8371d6-a6d0-4a2e-96c0-32726491b260?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/eb8371d6-a6d0-4a2e-96c0-32726491b260?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/eb8371d6-a6d0-4a2e-96c0-32726491b260?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/eb8371d6-a6d0-4a2e-96c0-32726491b260?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%20issue%20is%20caused%20by%20a%20breaking%20change%20in%20Better%20Auth%20%E2%89%A51.4.x%3A%20%60string%5B%5D%60%20fields%20in%20%60user.additionalFields%60%20are%20now%20stored%20as%20%60jsonb%60%20columns%20in%20PostgreSQL%2C%20not%20as%20native%20Postgres%20arrays.%20Drizzle%20ORM%20expects%20a%20native%20array%20%28e.g.%2C%20%60text%28%29.array%28%29%60%29%2C%20so%20when%20it%20receives%20a%20JSONB%20value%2C%20it%20throws%20a%20%60TypeError%3A%20value.map%20is%20not%20a%20function%60%20because%20it%27s%20trying%20to%20treat%20a%20JSON%20object%20as%20an%20array.%20The%20migration%20logic%20in%20Better%20Auth%20is%20responsible%20for%20this%20mapping%20%28%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/blob/a63e70ea27e2e936ae9915171c0e59054dc9b4a0/packages/better-auth/src/db/get-migration.ts%23L281-L395%29%29.%0A%0AMeanwhile%2C%20the%20Drizzle%20schema%20generator%20in%20Better%20Auth%20still%20emits%20native%20array%20columns%20for%20%60string%5B%5D%60%20%28%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/blob/a63e70ea27e2e936ae9915171c0e59054dc9b4a0/packages/cli/src/generators/drizzle.ts%23L20-L529%29%29%2C%20which%20creates%20a%20mismatch%20between%20the%20generated%20schema%20and%20the%20actual%20database%20column%20type.%0A%0A%2A%2AWorkaround%3A%2A%2A%20%20%0ATo%20resolve%20this%2C%20you%20can%20either%3A%0A-%20Change%20your%20Drizzle%20schema%20to%20use%20%60.jsonb%28%29%60%20for%20the%20affected%20field%2C%20so%20it%20matches%20the%20actual%20column%20type.%0A-%20Or%2C%20if%20you%20need%20native%20arrays%2C%20you%20would%20need%20to%20manually%20adjust%20the%20migration/schema%20logic%20in%20Better%20Auth%20to%20restore%20the%20previous%20behavior%20%28mapping%20%60string%5B%5D%60%20to%20native%20arrays%29%2C%20but%20there%20is%20currently%20no%20config%20option%20to%20do%20this.%0A%0AIf%20you%20need%20to%20migrate%20existing%20data%2C%20make%20sure%20to%20convert%20any%20array%20columns%20to%20JSONB%20before%20upgrading.%0A%0ALet%20me%20know%20if%20you%20need%20a%20code%20snippet%20for%20the%20workaround%20or%20have%20questions%20about%20migration%20steps.)&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/6779)
Author
Owner

@anthonyma94 commented on GitHub (Dec 15, 2025):

@dosu I cannot change the drizzle schema, show me how to manually adjust the logic in better auth.

<!-- gh-comment-id:3656400039 --> @anthonyma94 commented on GitHub (Dec 15, 2025): @dosu I cannot change the drizzle schema, show me how to manually adjust the logic in better auth.
Author
Owner

@dosubot[bot] commented on GitHub (Dec 15, 2025):

You need to edit the migration logic in Better Auth so that string[] fields are stored as native Postgres arrays (text[]) instead of jsonb. In your project, open packages/better-auth/src/db/get-migration.ts and find the typeMap object inside the getType function. Change the mapping for "string[]" under the postgres key from "jsonb" to "text[]":

"string[]": {
-    sqlite: "text",
-    postgres: "jsonb",
+    sqlite: "text",
+    postgres: "text[]",
     mysql: "json",
     mssql: "varchar(8000)",
},

Do the same for "number[]" if you use it.

After making this change, regenerate your migrations or re-run the migration process. If you already have data in the jsonb column, you'll need to migrate it to the new array column type manually (e.g., with a SQL migration that casts jsonb arrays to text[]).

This will align the generated schema with Drizzle's expectations and resolve the runtime error you’re seeing. You can verify the fix by checking that the generated migration SQL uses text[] for your array fields and by running your Drizzle queries without errors.
Reference: get-migration.ts typeMap

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:3656411528 --> @dosubot[bot] commented on GitHub (Dec 15, 2025): <!-- Answer --> You need to edit the migration logic in Better Auth so that string[] fields are stored as native Postgres arrays (text[]) instead of jsonb. In your project, open `packages/better-auth/src/db/get-migration.ts` and find the `typeMap` object inside the `getType` function. Change the mapping for `"string[]"` under the `postgres` key from `"jsonb"` to `"text[]"`: ```diff "string[]": { - sqlite: "text", - postgres: "jsonb", + sqlite: "text", + postgres: "text[]", mysql: "json", mssql: "varchar(8000)", }, ``` Do the same for `"number[]"` if you use it. After making this change, regenerate your migrations or re-run the migration process. If you already have data in the jsonb column, you'll need to migrate it to the new array column type manually (e.g., with a SQL migration that casts jsonb arrays to text[]). This will align the generated schema with Drizzle's expectations and resolve the runtime error you’re seeing. You can verify the fix by checking that the generated migration SQL uses `text[]` for your array fields and by running your Drizzle queries without errors. [Reference: get-migration.ts typeMap](https://github.com/better-auth/better-auth/blob/a63e70ea27e2e936ae9915171c0e59054dc9b4a0/packages/better-auth/src/db/get-migration.ts#L281-L544) <!-- 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/7c7af21e-cdc7-4d13-8f65-beebe296a2c7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/7c7af21e-cdc7-4d13-8f65-beebe296a2c7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/7c7af21e-cdc7-4d13-8f65-beebe296a2c7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/7c7af21e-cdc7-4d13-8f65-beebe296a2c7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7c7af21e-cdc7-4d13-8f65-beebe296a2c7?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/7c7af21e-cdc7-4d13-8f65-beebe296a2c7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/7c7af21e-cdc7-4d13-8f65-beebe296a2c7?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=You%20need%20to%20edit%20the%20migration%20logic%20in%20Better%20Auth%20so%20that%20string%5B%5D%20fields%20are%20stored%20as%20native%20Postgres%20arrays%20%28text%5B%5D%29%20instead%20of%20jsonb.%20In%20your%20project%2C%20open%20%60packages/better-auth/src/db/get-migration.ts%60%20and%20find%20the%20%60typeMap%60%20object%20inside%20the%20%60getType%60%20function.%20Change%20the%20mapping%20for%20%60%22string%5B%5D%22%60%20under%20the%20%60postgres%60%20key%20from%20%60%22jsonb%22%60%20to%20%60%22text%5B%5D%22%60%3A%0A%0A%60%60%60diff%0A%22string%5B%5D%22%3A%20%7B%0A-%20%20%20%20sqlite%3A%20%22text%22%2C%0A-%20%20%20%20postgres%3A%20%22jsonb%22%2C%0A%2B%20%20%20%20sqlite%3A%20%22text%22%2C%0A%2B%20%20%20%20postgres%3A%20%22text%5B%5D%22%2C%0A%20%20%20%20%20mysql%3A%20%22json%22%2C%0A%20%20%20%20%20mssql%3A%20%22varchar%288000%29%22%2C%0A%7D%2C%0A%60%60%60%0ADo%20the%20same%20for%20%60%22number%5B%5D%22%60%20if%20you%20use%20it.%0A%0AAfter%20making%20this%20change%2C%20regenerate%20your%20migrations%20or%20re-run%20the%20migration%20process.%20If%20you%20already%20have%20data%20in%20the%20jsonb%20column%2C%20you%27ll%20need%20to%20migrate%20it%20to%20the%20new%20array%20column%20type%20manually%20%28e.g.%2C%20with%20a%20SQL%20migration%20that%20casts%20jsonb%20arrays%20to%20text%5B%5D%29.%20%0A%0AThis%20will%20align%20the%20generated%20schema%20with%20Drizzle%27s%20expectations%20and%20resolve%20the%20runtime%20error%20you%E2%80%99re%20seeing.%20You%20can%20verify%20the%20fix%20by%20checking%20that%20the%20generated%20migration%20SQL%20uses%20%60text%5B%5D%60%20for%20your%20array%20fields%20and%20by%20running%20your%20Drizzle%20queries%20without%20errors.%20%20%0A%5BReference%3A%20get-migration.ts%20typeMap%5D%28https%3A//github.com/better-auth/better-auth/blob/a63e70ea27e2e936ae9915171c0e59054dc9b4a0/packages/better-auth/src/db/get-migration.ts%23L281-L544%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/6779)
Author
Owner

@ping-maxwell commented on GitHub (Dec 16, 2025):

Hey can you provide more context about "it errors out when referencing it."?

<!-- gh-comment-id:3658823952 --> @ping-maxwell commented on GitHub (Dec 16, 2025): Hey can you provide more context about "it errors out when referencing it."?
Author
Owner

@anthonyma94 commented on GitHub (Dec 16, 2025):

Yeah, the error in my issue happens when I try to create a user (calling /sign-up/email). I'm guessing somewhere along the way better-auth serialized the default array to a string but drizzle expects an array, hence value.map is not a function. It didn't do this before upgrading to 1.4.7 (1.4.0 is the latest I've tried that didn't throw this error).

<!-- gh-comment-id:3658888942 --> @anthonyma94 commented on GitHub (Dec 16, 2025): Yeah, the error in my issue happens when I try to create a user (calling /sign-up/email). I'm guessing somewhere along the way better-auth serialized the default array to a string but drizzle expects an array, hence `value.map is not a function`. It didn't do this before upgrading to 1.4.7 (1.4.0 is the latest I've tried that didn't throw this error).
Author
Owner

@anthonyma94 commented on GitHub (Jan 5, 2026):

@bytaesu I noticed you fixed #6975, can I get you to take a look at my issue when you get a chance? It's the same issue, but with the Drizzle adapter.

<!-- gh-comment-id:3710917988 --> @anthonyma94 commented on GitHub (Jan 5, 2026): @bytaesu I noticed you fixed #6975, can I get you to take a look at my issue when you get a chance? It's the same issue, but with the Drizzle adapter.
Author
Owner

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

Thanks @anthonyma94,
Let me check!

<!-- gh-comment-id:3711447756 --> @bytaesu commented on GitHub (Jan 5, 2026): Thanks @anthonyma94, Let me check!
Author
Owner

@ping-maxwell commented on GitHub (Jan 6, 2026):

Yeah, the error in my issue happens when I try to create a user (calling /sign-up/email). I'm guessing somewhere along the way better-auth serialized the default array to a string but drizzle expects an array, hence value.map is not a function. It didn't do this before upgrading to 1.4.7 (1.4.0 is the latest I've tried that didn't throw this error).

Hello just tested on my end and everything seems to be working fine.
I did notice from your issue that your customPermissions field has input: false meaning you shouldn't be able to use sign-up/email to pass that field in the first place?

Anyway could you provide more details with how your code is setup in the sign-up call? Maybe there is something there I need to replicate the issue.

<!-- gh-comment-id:3713094762 --> @ping-maxwell commented on GitHub (Jan 6, 2026): > Yeah, the error in my issue happens when I try to create a user (calling /sign-up/email). I'm guessing somewhere along the way better-auth serialized the default array to a string but drizzle expects an array, hence `value.map is not a function`. It didn't do this before upgrading to 1.4.7 (1.4.0 is the latest I've tried that didn't throw this error). Hello just tested on my end and everything seems to be working fine. I did notice from your issue that your `customPermissions` field has `input: false` meaning you shouldn't be able to use sign-up/email to pass that field in the first place? Anyway could you provide more details with how your code is setup in the sign-up call? Maybe there is something there I need to replicate the issue.
Author
Owner

@anthonyma94 commented on GitHub (Jan 6, 2026):

I tested 1.4.10 and it seems the issue is fixed (albeit didn't have much time to delve in deep). I'll close the issue and reopen a new one if I encounter more issues, thanks.

<!-- gh-comment-id:3715924433 --> @anthonyma94 commented on GitHub (Jan 6, 2026): I tested 1.4.10 and it seems the issue is fixed (albeit didn't have much time to delve in deep). I'll close the issue and reopen a new one if I encounter more issues, thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27950