Skip to content

Commit

Permalink
docs: Clarify create-only migration
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 6, 2024
1 parent 0286a89 commit 4df94c7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions prisma/docs/how-to-update-prisma-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ Make a change to this file which describes the change you would like to make (e.
Run `npm run prisma:migrate` - this will apply to the change to your local dev database, and generate a migration file in `/prisma/migrations`

> [!TIP]
> The command `npm run prisma:migrate-create-only` will generate a migration file without running it. This is helpful if you want to add any additional changes, and manually configure the migration. For example when renaming a column Prisma may drop and recreate (thus losing data). Manually generating an `ALTER table UPDATE column` SQL command allows us to work around this. You'll then need to run `npm run prisma:migrate` to apply your changes.
> The command `npm run prisma:migrate-create-only` will generate a migration file without running it. This is helpful if you want to add any additional changes, and manually configure the migration.
>
> For example when renaming a column Prisma may drop and recreate the column (thus losing data). Manually writing the correct SQL in the generated migration file (e.g. `ALTER table UPDATE column`) allows us to work around this. You'll then need to run `npm run prisma:migrate` to apply your changes.
>
> Docs: https://www.prisma.io/docs/orm/prisma-migrate/workflows/development-and-production#customizing-migrations
3. Update Prisma client
1. Update Prisma client
Run `npm run prisma:generate` to update your local client. You should now be able to both interact with the updated Prisma client as well as view the change in your local dev database.

4. Open PR, merge to `main`
1. Open PR, merge to `main`
From here, we can open the changes up to peer-review on GitHub. Once approved and merged, CI will apply our new migration to the production database using the "Deploy migrations" action (dir: `/.github/workflows/deploy-migrations.yaml`).

0 comments on commit 4df94c7

Please sign in to comment.