error: role "vscode" does not exist

vscode ➜ /workspaces/nethys/controlplane (master) $ bunx @better-auth/cli@latest generate
⠋ preparing schema.../workspaces/nethys/node_modules/pg-pool/index.js:45
Error.captureStackTrace(err)
^

error: role "vscode" does not exist
at /workspaces/nethys/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async PostgresDriver.acquireConnection (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:21:24)
at async RuntimeDriver.acquireConnection (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/driver/runtime-driver.js:44:28)
at async DefaultConnectionProvider.provideConnection (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/driver/default-connection-provider.js:8:28)
at async DefaultQueryExecutor.executeQuery (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
at async SelectQueryBuilderImpl.execute (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/query-builder/select-query-builder.js:317:24)
at async PostgresIntrospector.getTables (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/dialect/postgres/postgres-introspector.js:61:28)
at async getMigrations (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/better-auth/dist/shared/better-auth.XjdOGtZf.mjs:995:25)
at async generateMigrations (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/index.mjs:703:33) {
length: 98,
severity: 'FATAL',
code: '28000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'miscinit.c',
line: '703',
routine: 'InitializeSessionUserId'
}

Node.js v22.15.1
vscode ➜ /workspaces/nethys/controlplane (master) $ bunx @better-auth/cli@latest generate
⠋ preparing schema.../workspaces/nethys/node_modules/pg-pool/index.js:45
Error.captureStackTrace(err)
^

error: role "vscode" does not exist
at /workspaces/nethys/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async PostgresDriver.acquireConnection (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:21:24)
at async RuntimeDriver.acquireConnection (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/driver/runtime-driver.js:44:28)
at async DefaultConnectionProvider.provideConnection (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/driver/default-connection-provider.js:8:28)
at async DefaultQueryExecutor.executeQuery (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
at async SelectQueryBuilderImpl.execute (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/query-builder/select-query-builder.js:317:24)
at async PostgresIntrospector.getTables (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/kysely/dist/esm/dialect/postgres/postgres-introspector.js:61:28)
at async getMigrations (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/better-auth/dist/shared/better-auth.XjdOGtZf.mjs:995:25)
at async generateMigrations (file:///tmp/bunx-1000-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/index.mjs:703:33) {
length: 98,
severity: 'FATAL',
code: '28000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'miscinit.c',
line: '703',
routine: 'InitializeSessionUserId'
}

Node.js v22.15.1
I'm looking for either a different way to create a db schema for better-auth (i'm using kysely) or some way to fix this issue
Solution:
pass your db like this
Jump to solution
9 Replies
Blank
Blank4mo ago
it seems like your db uri is wrong
lyn
lynOP4mo ago
i have no idea how to pass a db uri what env var should i use? --help doesn't say
Blank
Blank4mo ago
you are using kysely hmm lemme check
Solution
Blank
Blank4mo ago
pass your db like this
lyn
lynOP4mo ago
ty oh wait i think i see why im having the issue now though my auth.ts looks like this:
...
export const auth = betterAuth({
database: new Pool({
connectionString: process.env.POSTGRES_CONNECTION_URI,
}),

emailAndPassword: {
enabled: true,
},

plugins: [username(), admin()],
});
...
export const auth = betterAuth({
database: new Pool({
connectionString: process.env.POSTGRES_CONNECTION_URI,
}),

emailAndPassword: {
enabled: true,
},

plugins: [username(), admin()],
});
im using workspaces, my .env is in the root but i'm executing the cli command from inside the workspace
Blank
Blank4mo ago
what is your postgres uri and where is your db
lyn
lynOP4mo ago
just did it
vscode ➜ /workspaces/nethys (master) $ bunx @better-auth/cli@latest generate --config controlplane/auth.ts
✔ Do you want to generate the schema to ./better-auth_migrations/2025-05-19T16-18-50.158Z.sql? … yes
2025-05-19T16:18:53.705Z SUCCESS [Better Auth]: 🚀 Schema was generated successfully!
vscode ➜ /workspaces/nethys (master) $ bunx @better-auth/cli@latest generate --config controlplane/auth.ts
✔ Do you want to generate the schema to ./better-auth_migrations/2025-05-19T16-18-50.158Z.sql? … yes
2025-05-19T16:18:53.705Z SUCCESS [Better Auth]: 🚀 Schema was generated successfully!
ty
Blank
Blank4mo ago
:Okay:

Did you find this page helpful?