Skip to content

Commit

Permalink
Add no-seed configuration to database:reset (#9112)
Browse files Browse the repository at this point in the history
Based on feedback here:
#9109 (comment)
  • Loading branch information
FelixMalfait authored Dec 18, 2024
1 parent deb37ed commit 45214fe
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
35 changes: 24 additions & 11 deletions packages/twenty-server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,30 @@
"database:reset": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"options": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- cache:flush",
"nx command-no-deps -- workspace:seed:dev"
],
"parallel": false
}
"configurations": {
"no-seed": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps -- ./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 -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- cache:flush",
"nx command-no-deps -- workspace:seed:dev"
],
"parallel": false
}
},
"defaultConfiguration": "seed"
}
}
}
2 changes: 1 addition & 1 deletion packages/twenty-server/scripts/setup-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ rawDataSource
]; // See https://supabase.github.io/wrappers/

for (const wrapper of supabaseWrappers) {
if (await checkForeignDataWrapperExists(wrapper)) {
if (await checkForeignDataWrapperExists(`${wrapper.toLowerCase()}_fdw`)) {
continue;
}
await performQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Note : you can run `npx nx run twenty-server:test:integration:with-db-reset` in

### Resetting the database

If you want to reset the database, you can run the following command:
If you want to reset and seed the database, you can run the following command:

```bash
npx nx run twenty-server:database:reset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ If you can't log in after setup:
1. Run the following commands:
```bash
docker exec -it twenty-server-1 yarn
docker exec -it twenty-server-1 npx nx database:reset
docker exec -it twenty-server-1 npx nx database:reset --configuration=no-seed
```
2. Restart the Docker containers:
```bash
docker-compose down
docker-compose up -d
```

Note the database:reset command will completely erase your database and recreate it from scratch.

#### Connection Issues Behind a Reverse Proxy

If you're running Twenty behind a reverse proxy and experiencing connection issues:
Expand Down

0 comments on commit 45214fe

Please sign in to comment.