-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(ci): Test Prisma migrations #160
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
"prisma:migrate": "dotenv -e .env.local npx prisma migrate dev", | ||
"prisma:studio": "dotenv -e .env.local npx prisma studio", | ||
"prisma:migrate": "dotenv -e .env.local -- npx prisma migrate dev", | ||
"prisma:migrate-create-only": "dotenv -e .env.local -- npx prisma migrate dev --create-only", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent way too long trying to get the --create-only
flag to be picked up here.
Classic case of RTFM 🤦 - explainer in docs here why the additional --
is required https://www.prisma.io/docs/orm/more/development-environment/environment-variables/managing-env-files-and-setting-variables#using-dotenv-cli-via-command-line
8c26476
to
cbbda36
Compare
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm being silly but I don't quite understand where "Manually generating an ALTER table UPDATE column
SQL command" should be happening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - updated the docs now. Is this any clearer?
Keen to jump on a call and demo this so we're all confident making changes 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one small q, super clear though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see! Thanks :)
What does this PR do?
--create-only
flag - without this Prisma would drop and recreate the column. I needed to manually write the correct SQL in the migration file.