Databse reset issue in dev docker server.

@thomast @Prastoin @charles Hello everyone, when I try to run the database reset command in my development Docker container using yarn nx database:reset twenty-server, I get this error
No description
10 Replies
Prastoin
Prastoin7d ago
Hey @Dhruvraj please try using npx
Dhruvraj
DhruvrajOP7d ago
i am trying to run this command in dokcer container so it is asking me to yarn install but it should be installed in docker right ?
No description
Prastoin
Prastoin7d ago
If you're running this within a twenty-server container then you indeed need to pass through the yarn nx script, I'm not sure if it has ever been used in a container before 🤔
"scripts": {
"nx": "NX_DEFAULT_PROJECT=twenty-server node ../../node_modules/nx/bin/nx.js",
"start:prod": "node dist/src/main",
"command:prod": "node dist/src/command/command",
"worker:prod": "node dist/src/queue-worker/queue-worker",
"database:init:prod": "npx ts-node ./scripts/setup-db.ts && yarn database:migrate:prod",
"database:migrate:prod": "npx -y typeorm migration:run -d dist/src/database/typeorm/metadata/metadata.datasource && npx -y typeorm migration:run -d dist/src/database/typeorm/core/core.datasource",
"clickhouse:migrate:prod": "node dist/src/database/clickhouse/migrations/run-migrations.js",
"typeorm": "../../node_modules/typeorm/.bin/typeorm"
},
"scripts": {
"nx": "NX_DEFAULT_PROJECT=twenty-server node ../../node_modules/nx/bin/nx.js",
"start:prod": "node dist/src/main",
"command:prod": "node dist/src/command/command",
"worker:prod": "node dist/src/queue-worker/queue-worker",
"database:init:prod": "npx ts-node ./scripts/setup-db.ts && yarn database:migrate:prod",
"database:migrate:prod": "npx -y typeorm migration:run -d dist/src/database/typeorm/metadata/metadata.datasource && npx -y typeorm migration:run -d dist/src/database/typeorm/core/core.datasource",
"clickhouse:migrate:prod": "node dist/src/database/clickhouse/migrations/run-migrations.js",
"typeorm": "../../node_modules/typeorm/.bin/typeorm"
},
What you can still do is update your local .env database credentials information to be hitting your dev remote database instead of your local Edit: Yes I don't think nx script entry was planned to be used in container, ../../ seems broken in the docker container double checking
Dhruvraj
DhruvrajOP7d ago
we are trying to run npx nx reset command in /app directory but we are unable to find nx
No description
Prastoin
Prastoin7d ago
That's because unless I'm mistaken nx is not shipped Please refer to
Dhruvraj
DhruvrajOP7d ago
we already try in /app/packages/twenty-server but it's not working
No description
Prastoin
Prastoin7d ago
As said above:
Edit: Yes I don't think nx script entry was planned to be used in container, ../../ seems broken in the docker container double checking
IMO you have two options either: 1/ ( recommended )
What you can still do is update your local .env database credentials information to be hitting your dev remote database instead of your local
2/ Build your own image that either ships database:reset yarn script entry mocking the nx command or ship nx
Jay Patel
Jay Patel7d ago
Thanks @Prastoin , 1 - on production, we have a private network setup so from the local we can't do a database:reset. So we'll try to go with 2nd approach.
Prastoin
Prastoin7d ago
No worries @Jay Patel You can find database:reset nx command detail in packages/twenty-server/project.json
"database:reset": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"configurations": {
"no-seed": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- cache:flush"
],
"parallel": false
},
"seed": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- cache:flush",
"nx command-no-deps -- workspace:seed:dev"
],
"parallel": false
}
},
"database:reset": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"configurations": {
"no-seed": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- cache:flush"
],
"parallel": false
},
"seed": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- cache:flush",
"nx command-no-deps -- workspace:seed:dev"
],
"parallel": false
}
},
@Jay Patel @Dhruvraj After double checking the nx command definition the below command might be enough for your use case
yarn command:prod workspace:seed:dev
yarn command:prod workspace:seed:dev
( to be run in your twenty-server container ) Please always do a backup before
Jay Patel
Jay Patel7d ago
@Prastoin okay 👍

Did you find this page helpful?