ai-chatbot icon indicating copy to clipboard operation
ai-chatbot copied to clipboard

ai-chatbot does not include instructions for DB migration on local deployments

Open b8zhong opened this issue 9 months ago • 4 comments

Database Migration Missing in Localhost Setup

Description

The current README lacks a crucial step for database initialization, causing authentication failures on first setup when running locally.

A similar issue, but was closed without PR change to documentation: https://github.com/vercel/ai-chatbot/issues/450

Current Behavior

Database-related errors when trying to register/login:

Image

Failed to get user from database
POST /register 200

Database migrations need to be run before the application can work properly.

pnpm tsx lib/db/migrate.ts && pnpm run build

b8zhong avatar Jan 27 '25 23:01 b8zhong

Did you tried running db:migrate?

kulterryan avatar Jan 28 '25 04:01 kulterryan

I encountered the same problem, Failed to get user from database

ilses1 avatar Feb 26 '25 11:02 ilses1

Hey everyone,

After completing the setup, I ran the application, and the sign-in page opened as expected. However, when I try to create a new account, I get an error saying, "Failed to create an account." Any ideas on what might be causing this?

anurag923 avatar Mar 24 '25 05:03 anurag923

Hi all 👋 there are already 3 existing PRs that are addressing this issue:

  • https://github.com/vercel/ai-chatbot/pull/855
  • https://github.com/vercel/ai-chatbot/pull/830
  • https://github.com/vercel/ai-chatbot/pull/732

@jeremyphilemon any chance we could get one of these PRs merged so that we can close this issue and make it easier for everyone to spin up the project locally?

Cheers

tobiasbueschel avatar Apr 01 '25 07:04 tobiasbueschel

+1 to prioritizing this — without clear migration instructions, most users will hit errors out of the box and give up before trying the chatbot. A quick note about running ts-node migrate.ts (or npm run migrate) would go a long way.

vidhant avatar Jul 16 '25 03:07 vidhant

Disappointing to see this is still not addressed.

ps: Thanks @b8zhong for the details

pavinduLakshan avatar Aug 02 '25 02:08 pavinduLakshan

The setup docs list setting DATABASE_URL:

Create a PostgreSQL database and retrieve its connection string to set the DATABASE_URL environment variable in .env.local

The actual ENV variable is POSTGRES_URL:

> npx tsx lib/db/migrate.ts

❌ Migration failed
Error: POSTGRES_URL is not defined
    at runMigrate (agent-spike/lib/db/migrate.ts:12:11)
    at postgres (agent-spike/lib/db/migrate.ts:28:1)
    at Object.<anonymous> (agent-spike/lib/db/migrate.ts:32:2)
    at Module._compile (node:internal/modules/cjs/loader:1723:14)
    at Object.transformer (agent-spike/node_modules/.pnpm/[email protected]/node_modules/tsx/dist/register-DCnOAxY2.cjs:2:1186)
    at Module.load (node:internal/modules/cjs/loader:1458:32)
    at Function._load (node:internal/modules/cjs/loader:1275:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at cjsLoader (node:internal/modules/esm/translators:311:5)
 ELIFECYCLE  Command failed with exit code 1.

techpeace avatar Sep 29 '25 14:09 techpeace

@dancer Why this is closed as not planned ? Do you think you need to spend hours for searching github issues to simply deploy this template locally ?

maver1ck avatar Nov 08 '25 15:11 maver1ck