I have setup a build pipeline on Azure to execute pytests and such. In addition, I'd also like to check if no migrations have been missed.
Running the alembic
command with --autogenerate
will generate a new migration file in case it isn't there yet.
When executing the revision command just by itself
alembic revision --autogenerate
the output looks something like this (1)
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.ddl.postgresql] Detected sequence ...
INFO [alembic.ddl.postgresql] Detected sequence ...
INFO [alembic.ddl.postgresql] Detected sequence ...
INFO [alembic.autogenerate.compare] Detected added column ...
Generating /.../alembic/versions/dc3dae7487df_.py ... done
I've tried it with the following check
[[ $(alembic revision --autogenerate | grep "^Generating.*done$") ]] && echo "test"
However, the grep doesn't seem to work on the alembic output since I never receive the echo test
even if a new migration file is generated.
Running the command
alembic revision --autogenerate | grep 'Generating.*done' | cat -v
produces the output as in (1).
Changing the regex also doesn't give the expected result
[[ $(alembic revision --autogenerate | grep "^[[:blank:]]*Generating.*done\r$") ]] && echo "test"