Post-migration script #531
-
Hi, I'd like to run a privileges script after every migration. Is this possible with DBMate? |
Beta Was this translation helpful? Give feedback.
Answered by
dossy
Mar 19, 2024
Replies: 1 comment 3 replies
-
Executing a script after each migration is applied is not currently possible within dbmate, or at least I cannot imagine a way to do so. What is the use case you're looking to implement? Maybe there is an alternative solution that is possible. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you need a single script executed after executing dbmate, you could wrap your execution of dbmate into a shell script that executes dbmate then executes your additional script. That would be the recommended approach.
If you need a script executed in between individual migration files as dbmate applies them in order, that's not something that dbmate is currently capable of. If
dbmate up
took a--limit
argument to control the number of migrations applied per run, it would be hypothetically possible to write a shell script that invokeddbmate
in a loop, applying--limit 1
migration file at a time, until there are no more migrations left to apply.It sounds like you only need a single scri…