Alembic migrations don't work out of the box
See original GitHub issueChecklist
- The bug is reproducible against the latest release and/or
master
. - There are no similar issues or pull requests to fix it yet.
Describe the bug
The documentation says “Because ORM is built on SQLAlchemy core, you can use Alembic to provide database migrations.”. However, running Alembic with the appropriate configuration (i.e., replacing the connection string with a non-async driver) produces empty migrations.
In order for Alembic to produce actual migrations, one can run MyModelName.build_table()
on all of the tables you want to produce migrations for. I actually don’t know if this is the “correct” way to do this, but the docs have no information and I came up empty searching for the source code for any clues.
Diving through the source code, I noticed that the build_table
method on Model
was the only place metadata
was being mutated (via the sqlalchemy.Table
class constructor), so I tried calling this class method, and lo-and-behold, it worked!
To reproduce
I can provide a repo if needed, since this could be a few minutes of work.
Expected behavior
Alembic works out of the box with encode/orm.
Actual behavior
Alembic generates empty migrations.
Environment
- OS: macOS 12.4 (21F79)
- Python version: Python 3.10.5
- ORM version: 0.3.1
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Just looked through, indeed you’re correct! Looks like this is unreleased code, though.
I didn’t think I’d need to test against master (instructions ask for repro on latest release and/or master–so apologies!)
No worries. Thanks for pointing this out. Feel free to add this to the docs and I will prepare the release.