Tutorial mentions following:
In practice create_all() is usually not an ideal solution. To manage database schema, tool like Alembic is recommended.
I followed Alembic docs about Auto Generating Migrations and it tells to do:
from myapp.mymodel import Base
target_metadata = Base.metadata
I imported my model class - got error about missing attribute. Same when I did it for base db.Model:
from widgets.models import db
target_metadata = db.Model.metadata
Documentation needs some section about where to get that metadata for alembic to autogenerate migrations.
Ah right, will add in FAQ. Thanks for the report!
db is just the metadata. So this will do:
from widgets.models import db as target_metadata
You can see this in a very outdated example here.
Awesome, it works.
For future reference, Here's a gist that you might find helpful:
https://gist.github.com/omarryhan/cb7bf6d7142c154496ba6623a56326c2
Trying to get Alembic and Gino working together as well, but I'm having some issues with running any Alembic commands, saying AttributeError: type object 'AsyncpgDBAPI' has no attribute 'connect'

@Ovyerus I don't know the context of the code you attached. Alembic doesn't support Python's async way, and Gino will only provide metadata or db schema that Alembic can use to infer the migration.
I believe underneath it uses psycopg2 to access PostgreSQL.
Alembic env.py in run_migrations_online. And turns out that the issue was because I forgot to replace the asyncpg in my URL with postgres so I guess it tried to use the asyncpg driver. Brain fart.
You can always use postgres:// or postgresql:// in URL, which works for both GINO and Alembic. Because the default driver of postgresql for GINO engine is asyncpg, therefore postgres:// is short for postgresql+asyncpg://; while for normal SQLAlchemy/Alembic, the default driver is psycopg2, the same short form shall be correctly expanded into postgresql+psycopg2://.
Ah, good to know 馃憤
Hey, I recently came across this situation. I am able to use alembic with gino and handle some basic migrations, but I really don't like the interaction between the two by different reasons:
Do you have a plan to deal with any of the issues I am seeing?
Best,
Jorge.
@jorgeecardona Thanks for pointing it out! I'm well aware of this issue. As I checked out code in Alembic, it currently can't support Python's async style.
The easy answer, I think, is to have an async version of Alembic, but it'll not be easy task. 馃槄
Closing this one as we have an example now.
@fantix Can I use this without Poetry? How do I run the load_modules() function without it? What goes in the for ep in entry_points["variable]?
@austincollinpena please also see this how-to by @xnuinside in #672
Most helpful comment
For future reference, Here's a gist that you might find helpful:
https://gist.github.com/omarryhan/cb7bf6d7142c154496ba6623a56326c2