OpenCut icon indicating copy to clipboard operation
OpenCut copied to clipboard

error when run "bun run db:push:local"

Open TanNguyenKhac opened this issue 1 year ago • 7 comments

error: password authentication failed for user "opencut":

$ cross-env NODE_ENV=development drizzle-kit push No config path provided, using default 'drizzle.config.ts' Reading config file 'E:\personal_projects\OpenCut\apps\web\drizzle.config.ts' Using 'pg' driver for database querying [⣷] Pulling schema from database... error: password authentication failed for user "opencut" at E:\personal_projects\OpenCut\node_modules\pg-pool\index.js:45:11 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Object.query (E:\personal_projects\OpenCut\node_modules\drizzle-kit\bin.cjs:80597:26) at async fromDatabase2 (E:\personal_projects\OpenCut\node_modules\drizzle-kit\bin.cjs:19253:25) { length: 103, severity: 'FATAL', code: '28P01', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'auth.c', line: '324', routine: 'auth_failed' }

TanNguyenKhac avatar Jul 12 '25 10:07 TanNguyenKhac

Have you ran the docker compose -d and copied the db string from .env.example to .env ?

DeepanshuMishraa avatar Jul 12 '25 10:07 DeepanshuMishraa

yes, i have ran. i try: docker run -it --rm -e PGPASSWORD=opencutthegoat postgres:17 psql -h host.docker.internal -p 5432 -U opencut -d opencut psql: error: connection to server at "host.docker.internal", port 5432 failed: FATAL: password authentication failed for user "opencut"

TanNguyenKhac avatar Jul 12 '25 10:07 TanNguyenKhac

This is likely an environment variable or Docker configuration issue. Quick check debugging steps:

  1. Check if Docker services are running: docker-compose ps

  2. Verify .env.local file exists in apps/web/: cd apps/web && ls -la .env*

  3. Common fix - Reset Docker volumes: docker-compose down -v docker-compose up -d

shivas1432 avatar Jul 12 '25 11:07 shivas1432

run docker run -e POSTGRES_PASSWORD=opencut -d -p 5432:5432 postgres and make sure the DATABASE_URL in .env is

DATABASE_URL="postgresql://postgres:opencut@localhost:5432/postgres"

Try this and let me know if this fixes the problem

DeepanshuMishraa avatar Jul 12 '25 11:07 DeepanshuMishraa

I've been running into a similar issue, but for running the initial migration. I've followed the steps from the README, running docker-compose up -d in root and copying my environment variables, making sure they match docker-compose.yaml. However, this is the error I receive when running the migration.

➜  web git:(main) ✗ bun run db:migrate                                               
$ drizzle-kit migrate
No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/gwiebel/Documents/Projects/OpenCut/apps/web/drizzle.config.ts'
Using 'pg' driver for database querying
[⣷] applying migrations...DrizzleQueryError: Failed query: CREATE SCHEMA IF NOT EXISTS "drizzle"
params: 
    at NodePgPreparedQuery.queryWithCache (/Users/gwiebel/Documents/Projects/OpenCut/node_modules/src/pg-core/session.ts:74:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async PgDialect.migrate (/Users/gwiebel/Documents/Projects/OpenCut/node_modules/src/pg-core/dialect.ts:85:3)
    at async migrate (/Users/gwiebel/Documents/Projects/OpenCut/node_modules/src/node-postgres/migrator.ts:10:2) {
  query: 'CREATE SCHEMA IF NOT EXISTS "drizzle"',
  params: [],
  cause: error: role "opencut" does not exist
      at /Users/gwiebel/Documents/Projects/OpenCut/node_modules/pg-pool/index.js:45:11
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async <anonymous> (/Users/gwiebel/Documents/Projects/OpenCut/node_modules/src/node-postgres/session.ts:149:14)
      at async NodePgPreparedQuery.queryWithCache (/Users/gwiebel/Documents/Projects/OpenCut/node_modules/src/pg-core/session.ts:72:12)
      at async PgDialect.migrate (/Users/gwiebel/Documents/Projects/OpenCut/node_modules/src/pg-core/dialect.ts:85:3)
      at async migrate (/Users/gwiebel/Documents/Projects/OpenCut/node_modules/src/node-postgres/migrator.ts:10:2) {
    ...
  }
}
error: script "db:migrate" exited with code 1

I've tried restarting my docker instances as outlined above and can confirm my docker services are healthy.

➜  web git:(main) ✗ docker-compose ps                                                                           
WARN[0000] The "GOOGLE_CLIENT_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GOOGLE_CLIENT_SECRET" variable is not set. Defaulting to a blank string. 
NAME                              IMAGE                                COMMAND                  SERVICE                 CREATED          STATUS                      PORTS
opencut-db-1                      postgres:17                          "docker-entrypoint.s…"   db                      12 minutes ago   Up 12 minutes (healthy)     0.0.0.0:5432->5432/tcp, [::]:5432->5432/tcp
opencut-redis-1                   redis:7-alpine                       "docker-entrypoint.s…"   redis                   12 minutes ago   Up 12 minutes (healthy)     0.0.0.0:6379->6379/tcp, [::]:6379->6379/tcp
opencut-serverless-redis-http-1   hiett/serverless-redis-http:latest   "_build/prod/rel/pro…"   serverless-redis-http   12 minutes ago   Up 12 minutes (healthy)     0.0.0.0:8079->80/tcp, [::]:8079->80/tcp
opencut-web-1                     opencut-web                          "/usr/local/bin/dock…"   web                     12 minutes ago   Up 12 minutes (unhealthy)   0.0.0.0:3100->3000/tcp, [::]:3100->3000/tcp

parion avatar Jul 14 '25 02:07 parion

run docker run -e POSTGRES_PASSWORD=opencut -d -p 5432:5432 postgres and make sure the DATABASE_URL in .env is

DATABASE_URL="postgresql://postgres:opencut@localhost:5432/postgres"

Try this and let me know if this fixes the problem

Just run this and then run the migration obv replace your db string with the given url

DeepanshuMishraa avatar Jul 14 '25 13:07 DeepanshuMishraa

I was able to verify your fix, thanks @DeepanshuMishraa!

parion avatar Jul 14 '25 15:07 parion