Apply some Prisma migrations only on certain environments

Viewed 26

I have two sets of environments I'd like to run checks differently on.

On the production database, there's a table that is append-only; a trigger prohibits deletes and updates.

However, for the sake of testing, on the test database I'd like to run deletes.

What would be the best practice for this, given I use Prisma migrations?

1 Answers

This is an interesting use case. One possible workaround is keeping a separate SQL file that disables/ deletes the trigger and executing it on your test database using prisma db execute after running prisma migrate deploy. I.e:

prisma db execute ./<path-to-file>/delete-trigger.sql

Feel free to refer to the prisma db execute CLI reference for further details. Let me know how it goes and don't hesitate to reach out if you run into any issue. :)

Related