Docs/prisma commands on docs (#1875)
* Update prisma commands Prisma commands have changed due to the new project structure * Set the type of code block to have code block style * Apply required changes * Update READMEpull/1930/head^2
parent
373bc1660c
commit
e36428de5d
|
@ -164,7 +164,7 @@ yarn dx
|
|||
1. Set up the database using the Prisma schema (found in `apps/web/prisma/schema.prisma`)
|
||||
|
||||
```sh
|
||||
yarn workspace @calcom/web prisma migrate deploy
|
||||
yarn workspace @calcom/prisma db-deploy
|
||||
```
|
||||
|
||||
1. Run (in development mode)
|
||||
|
@ -211,7 +211,7 @@ yarn workspace @calcom/web playwright-report
|
|||
In a development environment, run:
|
||||
|
||||
```sh
|
||||
yarn workspace @calcom/web prisma migrate dev
|
||||
yarn workspace @calcom/prisma db-migrate
|
||||
```
|
||||
|
||||
(this can clear your development database in some cases)
|
||||
|
@ -219,7 +219,7 @@ yarn workspace @calcom/web playwright-report
|
|||
In a production environment, run:
|
||||
|
||||
```sh
|
||||
yarn workspace @calcom/web prisma migrate deploy
|
||||
yarn workspace @calcom/prisma db-deploy
|
||||
```
|
||||
|
||||
3. Check the `.env.example` and compare it to your current `.env` file. In case there are any fields not present
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Database Migrations
|
||||
As described in the [upgrade guide](https://docs.cal.com/self-hosting/upgrading.md), you should use the `npx prisma migrate dev` or `npx prisma migrate deploy` command to update the database.
|
||||
As described in the [upgrade guide](https://docs.cal.com/self-hosting/upgrade), you should use the `yarn workspace @calcom/prisma db-migrate` or `yarn workspace @calcom/prisma db-deploy` command to update the database.
|
||||
|
||||
We use database migrations in order to handle changes to the database schema in a more secure and stable way. This is actually very common. The thing is that when just changing the schema in `schema.prisma` without creating migrations, the update to the newer database schema can damage or delete all data in production mode, since the system sometimes doesn't know how to transform the data from A to B. Using migrations, each step is reproducable, transparent and can be undone in a simple way.
|
||||
|
||||
|
@ -7,8 +7,8 @@ We use database migrations in order to handle changes to the database schema in
|
|||
If you are modifying the codebase and make a change to the `schema.prisma` file, you must create a migration.
|
||||
|
||||
To create a migration for your previously changed `schema.prisma`, simply run the following:
|
||||
```
|
||||
npx prisma migrate dev
|
||||
```sh
|
||||
yarn workspace @calcom/prisma db-migrate
|
||||
```
|
||||
|
||||
Now, you must create a short name for your migration to describe what changed (for example, "user_add_email_verified"). Then just add and commit it with the corresponding code that uses your new database schema.
|
||||
|
@ -21,7 +21,7 @@ Always keep an eye on what migrations Prisma is generating. Prisma often happily
|
|||
|
||||
## Error: The database schema is not empty
|
||||
Prisma uses a database called `_prisma_migrations` to keep track of which migrations have been applied and which haven't. If your local migrations database doesn't match up with what's in the actual database, then Prisma will throw the following error:
|
||||
```
|
||||
```text
|
||||
Error: P3005
|
||||
|
||||
The database schema for `localhost:5432` is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline
|
||||
|
@ -30,8 +30,8 @@ The database schema for `localhost:5432` is not empty. Read more about how to ba
|
|||
In order to fix this, we need to tell Prisma which migrations have already been applied.
|
||||
|
||||
This can be done by running the following command, replacing `migration_name` with each migration that you have already applied:
|
||||
```
|
||||
npx prisma migrate resolve --applied migration_name
|
||||
```sh
|
||||
yarn prisma migrate resolve --applied migration_name
|
||||
```
|
||||
|
||||
You will need to run the command for each migration that you want to mark as applied.
|
|
@ -30,12 +30,12 @@ or
|
|||
|
||||
3. Build and start calendso
|
||||
|
||||
```
|
||||
```bash
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
4. Start prisma studio
|
||||
```
|
||||
```bash
|
||||
docker-compose exec calendso -- npx prisma studio
|
||||
```
|
||||
5. Open a browser to [port 5555](http://localhost:5555) on your localhost to look at or modify the database content.
|
||||
|
|
|
@ -102,7 +102,7 @@ yarn dx
|
|||
1. Set up the database using the Prisma schema (found in `packages/prisma/schema.prisma`)
|
||||
|
||||
```sh
|
||||
npx prisma migrate deploy
|
||||
yarn workspace @calcom/prisma db-deploy
|
||||
```
|
||||
|
||||
1. Run (in development mode)
|
||||
|
|
|
@ -3,23 +3,23 @@
|
|||
**Warning**: When performing database migrations, you may lose data if the migration is not done properly.
|
||||
|
||||
1. Pull the current version:
|
||||
```
|
||||
```sh
|
||||
git pull
|
||||
```
|
||||
2. Apply database migrations by running <b>one of</b> the following commands:
|
||||
|
||||
In a development environment, run:
|
||||
|
||||
```
|
||||
npx prisma migrate dev
|
||||
```sh
|
||||
yarn workspace @calcom/prisma db-migrate
|
||||
```
|
||||
|
||||
(this can clear your development database in some cases)
|
||||
|
||||
In a production environment, run:
|
||||
|
||||
```
|
||||
npx prisma migrate deploy
|
||||
```sh
|
||||
yarn workspace @calcom/prisma db-deploy
|
||||
```
|
||||
|
||||
3. Check the `.env.example` and compare it to your current `.env` file. In case there are any fields not present
|
||||
|
@ -27,16 +27,16 @@
|
|||
|
||||
For the current version, especially check if the variable `BASE_URL` is present and properly set in your environment, for example:
|
||||
|
||||
```
|
||||
```text
|
||||
BASE_URL='https://yourdomain.com'
|
||||
```
|
||||
|
||||
4. Start the server. In a development environment, just do:
|
||||
```
|
||||
```sh
|
||||
yarn dev
|
||||
```
|
||||
For a production build, run for example:
|
||||
```
|
||||
```sh
|
||||
yarn build
|
||||
yarn start
|
||||
```
|
||||
|
|
|
@ -22,10 +22,10 @@ You need a PostgresDB database hosted somewhere. [Heroku](https://www.heroku.com
|
|||
yarn install
|
||||
```
|
||||
|
||||
4. Set up the database using the Prisma schema (found in `prisma/schema.prisma`)
|
||||
4. Set up the database using the Prisma schema (found in `packages/prisma/schema.prisma`)
|
||||
|
||||
```sh
|
||||
npx prisma migrate deploy
|
||||
yarn workspace @calcom/prisma db-deploy
|
||||
```
|
||||
|
||||
5. Open [Prisma Studio](https://www.prisma.io/studio) to look at or modify the database content:
|
||||
|
|
Loading…
Reference in New Issue