Add a new command to get latest schema from migration files instead of the db
Hello, I'm integrating pgroll with my app (it's open source so it's here and I found something that seems odd.
So with normal migrations I'd like to make sure that my app doesn't start unless the migrations for it has run (at least started or possibly completed). But I don't see that with pgroll.
For example rails or phoenix both refuse to start if the migrations for the project have not run, so I had to implement a couple of things by hand:
- Find the current last migration from the filesystem (which is something pgroll already does internally)
- Ensure that at least that migration has started to run or has been completed successfully
The docs here suggest hardcoding the current schema but I'd like to automate that since the app has that information in the fs.
My proposal are two commands (maybe one with a flag):
pgroll local current-migration --migrations-dir ./migrations: kind of likepgroll latest schemato get the schema that the app expects (not necessarily the one that shows up on the db)pgroll up-to-date --url postgresql://... --migrations-dir ./migrations: I'd like this command to read from the fs the migrations that exist, read from the db the migrations that have been applied and check if the db has at least all the migrations from the fs run (or at least started)
I could give it a go at implementing those features since it looks like it's something that almost happening but not exposed
Source: xataio/pgroll