[GH-ISSUE #4795] auth.api.signUpEmail error after migration from supabase #10072

Closed
opened 2026-04-13 05:59:06 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @Stealthwriter on GitHub (Sep 21, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4795

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I ran npx @better-auth/cli migrate

The tables where created in the public folder in supabase

but when i try to signup a user I get this error:

2025-09-21T06:55:10.847Z ERROR [Better Auth]: Failed to create user error: column "role" of relation "user" does not exist
at async signUpAction (src\app\auth\sign-up\signup-actions.tsx:45:5)
at async signUpAction (src\app\auth\sign-up\signup-actions.tsx:45:5)
43 |
44 | try {

45 | await auth.api.signUpEmail({
| ^
46 | body: {
47 | name,
48 | email, {
length: 121,
severity: 'ERROR',
code: '42703',
detail: undefined,
hint: undefined,
position: '81',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_target.c',
line: '1065',
routine: 'checkInsertTargets'
}

Current vs. Expected behavior

should signup a user

What version of Better Auth are you using?

1.3

System info

nextjs

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @Stealthwriter on GitHub (Sep 21, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4795 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I ran npx @better-auth/cli migrate The tables where created in the public folder in supabase but when i try to signup a user I get this error: 2025-09-21T06:55:10.847Z ERROR [Better Auth]: Failed to create user error: column "role" of relation "user" does not exist at async signUpAction (src\app\auth\sign-up\signup-actions.tsx:45:5) at async signUpAction (src\app\auth\sign-up\signup-actions.tsx:45:5) 43 | 44 | try { > 45 | await auth.api.signUpEmail({ | ^ 46 | body: { 47 | name, 48 | email, { length: 121, severity: 'ERROR', code: '42703', detail: undefined, hint: undefined, position: '81', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'parse_target.c', line: '1065', routine: 'checkInsertTargets' } ### Current vs. Expected behavior should signup a user ### What version of Better Auth are you using? 1.3 ### System info ```bash nextjs ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 05:59:06 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 21, 2025):

The error occurs because the Better Auth migration scripts do not create a role column in the user table by default for Supabase/Postgres or other supported databases. The standard schema includes fields like id, name, email, emailVerified, image, createdAt, and updatedAt, but not role source.

Your application logic or signup API is likely referencing a role column that doesn't exist in the migrated schema. To fix this, you can either:

  • Add a role column to your user table in Supabase (for example: ALTER TABLE "user" ADD COLUMN "role" TEXT;), or
  • Adjust your application logic to avoid referencing role if it isn't required.

This pattern of schema mismatches causing signup errors is established in other cases as well, such as with the name field source. If you need to add the role column, a simple TEXT type is usually sufficient unless your app requires something more specific.

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:3315554744 --> @dosubot[bot] commented on GitHub (Sep 21, 2025): <!-- Answer --> The error occurs because the Better Auth migration scripts do not create a `role` column in the `user` table by default for Supabase/Postgres or other supported databases. The standard schema includes fields like `id`, `name`, `email`, `emailVerified`, `image`, `createdAt`, and `updatedAt`, but not `role` [source](https://github.com/better-auth/better-auth/pull/4375). Your application logic or signup API is likely referencing a `role` column that doesn't exist in the migrated schema. To fix this, you can either: - Add a `role` column to your `user` table in Supabase (for example: `ALTER TABLE "user" ADD COLUMN "role" TEXT;`), or - Adjust your application logic to avoid referencing `role` if it isn't required. This pattern of schema mismatches causing signup errors is established in other cases as well, such as with the `name` field [source](https://github.com/better-auth/better-auth/issues/3394). If you need to add the `role` column, a simple `TEXT` type is usually sufficient unless your app requires something more specific. <!-- 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/cb89ca7a-d4e7-420c-9f4f-cfed9b7012ae?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/cb89ca7a-d4e7-420c-9f4f-cfed9b7012ae?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/cb89ca7a-d4e7-420c-9f4f-cfed9b7012ae?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/cb89ca7a-d4e7-420c-9f4f-cfed9b7012ae?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cb89ca7a-d4e7-420c-9f4f-cfed9b7012ae?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/cb89ca7a-d4e7-420c-9f4f-cfed9b7012ae?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cb89ca7a-d4e7-420c-9f4f-cfed9b7012ae?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/4795)
Author
Owner

@Stealthwriter commented on GitHub (Sep 21, 2025):

but why await auth.api.signUpEmail is adding to a row column? is the issue from supabase?

await auth.api.signUpEmail({
body: {
name,
email,
password,
callbackURL: "/auth/sign-up/verified",
},

<!-- gh-comment-id:3315560968 --> @Stealthwriter commented on GitHub (Sep 21, 2025): but why await auth.api.signUpEmail is adding to a row column? is the issue from supabase? await auth.api.signUpEmail({ body: { name, email, password, callbackURL: "/auth/sign-up/verified", },
Author
Owner

@dosubot[bot] commented on GitHub (Sep 21, 2025):

Better Auth's signUpEmail only inserts fields defined in its internal user schema—like name, email, and password—and does not reference a role column by default. If you're seeing an error about the missing role column, it's likely because your application code, a plugin, or some custom logic is trying to insert or reference role during sign-up, but the migration did not create that column in Supabase. This is not an issue with Supabase itself, but rather a schema mismatch between your code and the database.

To fix this, either add a role column to your user table in Supabase, or update your code to avoid referencing role unless you actually need it. Custom fields like role require explicit schema and migration support—Better Auth won't insert extra fields unless you configure it to do so source.

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:3315564879 --> @dosubot[bot] commented on GitHub (Sep 21, 2025): <!-- Answer --> Better Auth's `signUpEmail` only inserts fields defined in its internal user schema—like `name`, `email`, and `password`—and does not reference a `role` column by default. If you're seeing an error about the missing `role` column, it's likely because your application code, a plugin, or some custom logic is trying to insert or reference `role` during sign-up, but the migration did not create that column in Supabase. This is not an issue with Supabase itself, but rather a schema mismatch between your code and the database. To fix this, either add a `role` column to your `user` table in Supabase, or update your code to avoid referencing `role` unless you actually need it. Custom fields like `role` require explicit schema and migration support—Better Auth won't insert extra fields unless you configure it to do so [source](https://github.com/better-auth/better-auth/issues/3394). <!-- 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/757c7fc9-1f5d-4a53-98ac-bf7ff260b274?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/757c7fc9-1f5d-4a53-98ac-bf7ff260b274?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/757c7fc9-1f5d-4a53-98ac-bf7ff260b274?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/757c7fc9-1f5d-4a53-98ac-bf7ff260b274?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/757c7fc9-1f5d-4a53-98ac-bf7ff260b274?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/757c7fc9-1f5d-4a53-98ac-bf7ff260b274?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/757c7fc9-1f5d-4a53-98ac-bf7ff260b274?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/4795)
Author
Owner

@Stealthwriter commented on GitHub (Sep 21, 2025):

I tried to use a basic auth.ts file and it worked fine

but when i use this auth.ts file the issue happens:

import { betterAuth } from "better-auth"
import { Pool } from "pg"
import { admin } from "better-auth/plugins"
import { anonymous } from "better-auth/plugins"
import { nextCookies } from "better-auth/next-js";
import { sendEmail } from "../utils/mailer";

export const auth = betterAuth({
emailAndPassword: {
enabled: true,
autoSignIn: false,
requireEmailVerification: true,
minPasswordLength: 8,
maxPasswordLength: 100,
sendResetPassword: async ({user, url}, request) => {
await sendEmail({
to: user.email,
subject: "Reset your password",
text: Click the link to reset your password: ${url},
html: <p>Click the link to reset your password:</p><p><a href="${url}">${url}</a></p>
});
}
},
emailVerification: {
sendOnSignUp: true,
sendVerificationEmail: async ({ user, url }, request) => {
await sendEmail({
to: user.email,
subject: "Verify your email address",
text: Click the link to verify your email: ${url},
html: <p>Click the link to verify your email:</p><p><a href="${url}">${url}</a></p>
});
}
},
database: new Pool({
connectionString: "postgres://postgres:hidden@db.hidden.supabase.co:5432/postgres"
}),

socialProviders: {
    google: { 
        clientId: "hidden", 
        clientSecret: "hidden", 
    }, 
},

plugins: [admin(), anonymous(), nextCookies()]

})

<!-- gh-comment-id:3315568193 --> @Stealthwriter commented on GitHub (Sep 21, 2025): I tried to use a basic auth.ts file and it worked fine but when i use this auth.ts file the issue happens: import { betterAuth } from "better-auth" import { Pool } from "pg" import { admin } from "better-auth/plugins" import { anonymous } from "better-auth/plugins" import { nextCookies } from "better-auth/next-js"; import { sendEmail } from "../utils/mailer"; export const auth = betterAuth({ emailAndPassword: { enabled: true, autoSignIn: false, requireEmailVerification: true, minPasswordLength: 8, maxPasswordLength: 100, sendResetPassword: async ({user, url}, request) => { await sendEmail({ to: user.email, subject: "Reset your password", text: `Click the link to reset your password: ${url}`, html: `<p>Click the link to reset your password:</p><p><a href="${url}">${url}</a></p>` }); } }, emailVerification: { sendOnSignUp: true, sendVerificationEmail: async ({ user, url }, request) => { await sendEmail({ to: user.email, subject: "Verify your email address", text: `Click the link to verify your email: ${url}`, html: `<p>Click the link to verify your email:</p><p><a href="${url}">${url}</a></p>` }); } }, database: new Pool({ connectionString: "postgres://postgres:hidden@db.hidden.supabase.co:5432/postgres" }), socialProviders: { google: { clientId: "hidden", clientSecret: "hidden", }, }, plugins: [admin(), anonymous(), nextCookies()] })
Author
Owner

@dosubot[bot] commented on GitHub (Sep 21, 2025):

The error only happens with your complex auth.ts because the admin plugin expects a role column in your user table. The default Better Auth migration does not create this column, but the admin plugin references it for role-based access control, which triggers the error during signup when the column is missing (source, source).

To fix this, add a role column to your user table in Supabase/Postgres. A simple migration would be:

ALTER TABLE "user" ADD COLUMN "role" TEXT DEFAULT 'user';

If you want stricter role management, you can use an enum type and set a default value, for example:

CREATE TYPE role_enum AS ENUM ('admin', 'user', 'retailer', 'partner');
ALTER TABLE "user" ADD COLUMN "role" role_enum NOT NULL DEFAULT 'user';

After this, your signup should work as expected with the admin plugin enabled. If you add other plugins that expect extra fields, make sure your schema matches their requirements to avoid similar issues (source).

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:3315572515 --> @dosubot[bot] commented on GitHub (Sep 21, 2025): <!-- Answer --> The error only happens with your complex auth.ts because the admin plugin expects a role column in your user table. The default Better Auth migration does not create this column, but the admin plugin references it for role-based access control, which triggers the error during signup when the column is missing ([source](https://github.com/better-auth/better-auth/issues/3513), [source](https://github.com/better-auth/better-auth/issues/244)). To fix this, add a role column to your user table in Supabase/Postgres. A simple migration would be: ```sql ALTER TABLE "user" ADD COLUMN "role" TEXT DEFAULT 'user'; ``` If you want stricter role management, you can use an enum type and set a default value, for example: ```sql CREATE TYPE role_enum AS ENUM ('admin', 'user', 'retailer', 'partner'); ALTER TABLE "user" ADD COLUMN "role" role_enum NOT NULL DEFAULT 'user'; ``` After this, your signup should work as expected with the admin plugin enabled. If you add other plugins that expect extra fields, make sure your schema matches their requirements to avoid similar issues ([source](https://github.com/better-auth/better-auth/issues/2405)). <!-- 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/73d348ed-fa66-4e0b-b0a0-45641112553f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/73d348ed-fa66-4e0b-b0a0-45641112553f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/73d348ed-fa66-4e0b-b0a0-45641112553f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/73d348ed-fa66-4e0b-b0a0-45641112553f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/73d348ed-fa66-4e0b-b0a0-45641112553f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/73d348ed-fa66-4e0b-b0a0-45641112553f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/73d348ed-fa66-4e0b-b0a0-45641112553f?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/4795)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10072