From e36428de5d9cdfb7af493f8fb264c0400c7acc44 Mon Sep 17 00:00:00 2001 From: Miguel Nieto A <39246879+miguelnietoa@users.noreply.github.com> Date: Mon, 21 Feb 2022 15:47:50 -0500 Subject: [PATCH] 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 README --- README.md | 6 +++--- apps/docs/pages/developer/migrations.mdx | 14 +++++++------- apps/docs/pages/self-hosting/docker.mdx | 6 +++--- apps/docs/pages/self-hosting/install.mdx | 2 +- apps/docs/pages/self-hosting/upgrade.mdx | 18 +++++++++--------- apps/docs/pages/self-hosting/vercel.mdx | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 45723a9fe4..925b32a38f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/apps/docs/pages/developer/migrations.mdx b/apps/docs/pages/developer/migrations.mdx index 04d1de9d2a..f4dde2a31b 100644 --- a/apps/docs/pages/developer/migrations.mdx +++ b/apps/docs/pages/developer/migrations.mdx @@ -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. \ No newline at end of file +You will need to run the command for each migration that you want to mark as applied. diff --git a/apps/docs/pages/self-hosting/docker.mdx b/apps/docs/pages/self-hosting/docker.mdx index da71e38476..bb8668e433 100644 --- a/apps/docs/pages/self-hosting/docker.mdx +++ b/apps/docs/pages/self-hosting/docker.mdx @@ -15,7 +15,7 @@ Make sure you have `docker` & `docker-compose` installed on the server / system. ```bash docker pull calendso/calendso ``` - + or ### Option #2: Cloning @@ -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. diff --git a/apps/docs/pages/self-hosting/install.mdx b/apps/docs/pages/self-hosting/install.mdx index da881b65a6..029bfb2fbb 100644 --- a/apps/docs/pages/self-hosting/install.mdx +++ b/apps/docs/pages/self-hosting/install.mdx @@ -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) diff --git a/apps/docs/pages/self-hosting/upgrade.mdx b/apps/docs/pages/self-hosting/upgrade.mdx index 2db0ff7f76..edab102616 100644 --- a/apps/docs/pages/self-hosting/upgrade.mdx +++ b/apps/docs/pages/self-hosting/upgrade.mdx @@ -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 one of 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,17 +27,17 @@ 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 ``` -5. Enjoy the new version. \ No newline at end of file +5. Enjoy the new version. diff --git a/apps/docs/pages/self-hosting/vercel.mdx b/apps/docs/pages/self-hosting/vercel.mdx index b92daf79c4..68d12d04ca 100644 --- a/apps/docs/pages/self-hosting/vercel.mdx +++ b/apps/docs/pages/self-hosting/vercel.mdx @@ -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: