Files
twenty_crm/packages/twenty-website/src/content/developers/backend-development/server-commands.mdx
BOHEUS d350662984 Fix docs with missing npx (#8288)
Related to #8082

Created this PR on purpose after both #8083 and #8161 were closed and
respective branches were deleted by the author
2024-11-03 16:49:36 +01:00

99 lines
2.2 KiB
Plaintext

---
title: Backend Commands
icon: TbTerminal
image: /images/user-guide/kanban-views/kanban.png
---
## Useful commands
These commands should be executed from packages/twenty-server folder.
From any other folder you can run `npx nx <command> twenty-server` (or `npx nx run twenty-server:<command>`).
### First time setup
```
npx nx database:reset twenty-server # setup the database with dev seeds
```
### Starting the server
```
npx nx run twenty-server:start
```
### Lint
```
npx nx run twenty-server:lint # pass --fix to fix lint errors
```
### Test
```
npx nx run twenty-server:test:unit
```
### Resetting the database
If you want to reset the database, you can run the following command:
```bash
npx nx run twenty-server:database:reset
```
### Migrations
#### For objects in Core/Metadata schemas (TypeORM)
```bash
npx nx run twenty-server:typeorm --migration:generate src/database/typeorm/metadata/migrations/nameOfYourMigration -d src/database/typeorm/metadata/metadata.datasource.ts # replace by core data source if necessary
```
#### For Workspace objects
There are no migrations files, migration are generated automatically for each workspace,
stored in the database, and applied with this command
```bash
npx nx run twenty-server:command workspace:sync-metadata -f
```
<ArticleWarning>
This will drop the database and re-run the migrations and seed.
Make sure to back up any data you want to keep before running this command.
</ArticleWarning>
## Tech Stack
Twenty primarily uses NestJS for the backend.
Prisma was the first ORM we used. But in order to allow users to create custom fields and custom objects, a lower-level made more sense as we need to have fine-grained control. The project now uses TypeORM.
Here's what the tech stack now looks like.
**Core**
- [NestJS](https://nestjs.com/)
- [TypeORM](https://typeorm.io/)
- [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server)
**Database**
- [Postgres](https://www.postgresql.org/)
**Third-party integrations**
- [Sentry](https://sentry.io/welcome/) for tracking bugs
**Testing**
- [Jest](https://jestjs.io/)
**Tooling**
- [Yarn](https://yarnpkg.com/)
- [ESLint](https://eslint.org/)
**Development**
- [AWS EKS](https://aws.amazon.com/eks/)
<ArticleEditContent></ArticleEditContent>