Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fresh setup of PostgreSQL database Docker container fails #8701

Open
BOHEUS opened this issue Nov 23, 2024 · 0 comments
Open

Fresh setup of PostgreSQL database Docker container fails #8701

BOHEUS opened this issue Nov 23, 2024 · 0 comments

Comments

@BOHEUS
Copy link
Contributor

BOHEUS commented Nov 23, 2024

As I transitioned from old Postgres bitnami container to new Postgres spilo container as it's mentioned in docs, I stumped upon error when running npx nx database:reset twenty-server. It turns out that script responsible for resetting database and configuring it, has problem with creating new user.

Here's my workaround:

  • docker exec -it twenty_pg bash to access directly container's console
  • psql postgres -c "CREATE DATABASE default;" -c "CREATE DATABASE test;" -c "CREATE USER twenty PASSWORD 'twenty';" -c "ALTER ROLE twenty superuser;" taken from docs (if it doesn't work, run psql -U postgres and type each command separately)
    After that, when running npx nx database:reset twenty-server worked fine like before

Logs:

> npx nx database:reset twenty-server

   ✔  1/1 dependent project tasks succeeded [1 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————


> nx run twenty-server:build  [local cache]

> rimraf dist

> nest build --path ./tsconfig.build.json

-  TSC  Initializing type checker...
✔  TSC  Initializing type checker...
>  TSC  Found 0 issues.
>  SWC  Running...
Successfully compiled: 1653 files with swc (707.62ms)

> nx run twenty-server:"database:reset"

> nx ts-node-no-deps -- ./scripts/truncate-db.ts


> nx run twenty-server:ts-node-no-deps ./scripts/truncate-db.ts

> ts-node ./scripts/truncate-db.ts

Error during schema dropping: error: password authentication failed for user "twenty"
    at Parser.parseErrorMessage (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 102,
  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: '326',
  routine: 'auth_failed'
}

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target ts-node-no-deps for project twenty-server (7s)

      With additional flags:
        ./scripts/truncate-db.ts

> nx ts-node-no-deps -- ./scripts/setup-db.ts


> nx run twenty-server:ts-node-no-deps ./scripts/setup-db.ts

> ts-node ./scripts/setup-db.ts

Error during Data Source initialization: error: password authentication failed for user "twenty"
    at Parser.parseErrorMessage (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 102,
  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: '326',
  routine: 'auth_failed'
}

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target ts-node-no-deps for project twenty-server (6s)

      With additional flags:
        ./scripts/setup-db.ts

> nx database:migrate


   ✔  1/1 dependent project tasks succeeded [1 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————


> nx run twenty-server:build  [existing outputs match the cache, left as is]

> rimraf dist

> nest build --path ./tsconfig.build.json

-  TSC  Initializing type checker...
✔  TSC  Initializing type checker...
>  TSC  Found 0 issues.
>  SWC  Running...
Successfully compiled: 1653 files with swc (707.62ms)

> nx run twenty-server:"database:migrate"

> nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource


> nx run twenty-server:typeorm migration:run -d src/database/typeorm/metadata/metadata.datasource

> ts-node ../../node_modules/typeorm/cli.js migration:run -d src/database/typeorm/metadata/metadata.datasource

Error during migration run:
error: password authentication failed for user "twenty"
    at Parser.parseErrorMessage (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 102,
  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: '326',
  routine: 'auth_failed'
}
Warning: command "ts-node ../../node_modules/typeorm/cli.js migration:run -d src/database/typeorm/metadata/metadata.datasource" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target typeorm for project twenty-server (829ms)

      With additional flags:
        migration:run
        --d=src/database/typeorm/metadata/metadata.datasource

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]

Warning: command "nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target database:migrate for project twenty-server and 2 task(s) they depend on (1s)

   ✖  1/3 failed
   ✔  2/3 succeeded [2 read from cache]

Warning: command "nx database:migrate" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target database:reset for project twenty-server and 2 task(s) they depend on (14s)

   ✖  1/3 failed
   ✔  2/3 succeeded [2 read from cache]

➜  twenty git:(6638_authorization_token_env) ✗ npx nx database:reset twenty-server

   ✔  1/1 dependent project tasks succeeded [1 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————


> nx run twenty-server:build  [existing outputs match the cache, left as is]

> rimraf dist

> nest build --path ./tsconfig.build.json

-  TSC  Initializing type checker...
✔  TSC  Initializing type checker...
>  TSC  Found 0 issues.
>  SWC  Running...
Successfully compiled: 1653 files with swc (707.62ms)

> nx run twenty-server:"database:reset"

> nx ts-node-no-deps -- ./scripts/truncate-db.ts


> nx run twenty-server:ts-node-no-deps ./scripts/truncate-db.ts

> ts-node ./scripts/truncate-db.ts

Error during schema dropping: error: password authentication failed for user "twenty"
    at Parser.parseErrorMessage (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 102,
  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: '326',
  routine: 'auth_failed'
}

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target ts-node-no-deps for project twenty-server (6s)

      With additional flags:
        ./scripts/truncate-db.ts

> nx ts-node-no-deps -- ./scripts/setup-db.ts


> nx run twenty-server:ts-node-no-deps ./scripts/setup-db.ts

> ts-node ./scripts/setup-db.ts

Error during Data Source initialization: error: password authentication failed for user "twenty"
    at Parser.parseErrorMessage (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 102,
  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: '326',
  routine: 'auth_failed'
}

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target ts-node-no-deps for project twenty-server (6s)

      With additional flags:
        ./scripts/setup-db.ts

> nx database:migrate


   ✔  1/1 dependent project tasks succeeded [1 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————


> nx run twenty-server:build  [existing outputs match the cache, left as is]

> rimraf dist

> nest build --path ./tsconfig.build.json

-  TSC  Initializing type checker...
✔  TSC  Initializing type checker...
>  TSC  Found 0 issues.
>  SWC  Running...
Successfully compiled: 1653 files with swc (707.62ms)

> nx run twenty-server:"database:migrate"

> nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource


> nx run twenty-server:typeorm migration:run -d src/database/typeorm/metadata/metadata.datasource

> ts-node ../../node_modules/typeorm/cli.js migration:run -d src/database/typeorm/metadata/metadata.datasource

Error during migration run:
error: password authentication failed for user "twenty"
    at Parser.parseErrorMessage (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/home/user/Desktop/projects/twenty/node_modules/pg/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 102,
  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: '326',
  routine: 'auth_failed'
}
Warning: command "ts-node ../../node_modules/typeorm/cli.js migration:run -d src/database/typeorm/metadata/metadata.datasource" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target typeorm for project twenty-server (814ms)

      With additional flags:
        migration:run
        --d=src/database/typeorm/metadata/metadata.datasource

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]

Warning: command "nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target database:migrate for project twenty-server and 2 task(s) they depend on (1s)

   ✖  1/3 failed
   ✔  2/3 succeeded [2 read from cache]

Warning: command "nx database:migrate" exited with non-zero status code
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target database:reset for project twenty-server and 2 task(s) they depend on (13s)

   ✖  1/3 failed
   ✔  2/3 succeeded [2 read from cache]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant