I'm extending a 3rd party application which internally uses SQLAlchemy and Alembic. This is good, because I need to extend the database model of this application but I don't want to fork the project.
So, I'm trying to use alembic in my extension package.
alembic recognize that the database is already using alembic, so I cannot just start a new alembic configuration in my package as it try to find the hash of the last alembic upgrade.
I tried to assert that my step depeds on the last alembic upgrade:
revision = "my-autogenerated-revision"
down_revision = "last-revision-of-3rd-party-package"
branch_labels = None
depends_on = None
But alembic then raise an error has it cannot find the last-revision-of-3rd-party-package
definition.
- I need a way to configure alembic to use additional folders for looking for version upgrades.
Looking at the .ini file, I found this section:
# version location specification; This defaults
# to alembic/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
# version_locations = %(here)s/bar:%(here)s/bat:alembic/versions
This works, I can use something like this:
version_locations = %(here)s/alembic/versions:/path/to/the/other/package/alembic/versions
But this is an hardcoded path.
Is it possible to generally identify versions upgrade from a package, in an OS independent way? Something like:
version_locations = %(here)s/alembic/versions:%(package:xxx.yyy)/alembic/versions