Skip to content
Discussion options

You must be logged in to vote

Automating Post-Migration Tasks (GRANTs, etc.)

I see you're looking for a way to automate database permissions after running prisma migrate. While Prisma doesn't currently have a built-in "post-migration hook" in the schema.prisma file, there are two established ways to handle this in a production workflow.

1. The "Custom Script" Wrapper (Recommended)

The most robust way is to wrap your migration command in a script (Bash or JS) that runs your GRANT statements immediately after the migration succeeds. This ensures the logic is versioned alongside your app.

Example migrate.sh:

#!/bin/bash
npx prisma migrate deploy
if [ $? -eq 0 ]; then
  echo "Migration successful, applying permissions..."
  

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@gcb
Comment options

Answer selected by gcb
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
discussion/needs-confirmation Needs a user to confirm the solution before the Discussion can be marked as answered
4 participants