using alembic migration #139
Unanswered
nbraun-wolf
asked this question in
Q&A
Replies: 2 comments 4 replies
-
Yes that's possible, but it's a bit complicated for now, we need to fix it: You run # models.py
...
class Product(orm.Model):
tablename = "products"
registry = models
fields = {
"id": orm.Integer(primary_key=True),
"name": orm.String(max_length=100),
"rating": orm.Integer(minimum=1, maximum=5),
"in_stock": orm.Boolean(default=False),
}
metadata = models.metadata And for alembic: # env.py
...
from models import metadata
target_metadata = metadata And then running |
Beta Was this translation helpful? Give feedback.
2 replies
-
And if you're interested to contribute: We need to change this: Line 28 in c6b9c0e To: self._metadata = sqlalchemy.MetaData() And add a metadata property: @property
def metadata():
for model_cls in self.models.values():
model_cls.build_table()
return metadata We need this in a few other places too. If you have any feedback or would like to contribute, feel free. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I am having a lot of trouble using the databases package with SQL alchemy, so I am looking for alternatives. Is it possible to use this ORM with alembic?
Edit:
Sorry, I haven't seen this sentence in the README. So, seems like it's possible. Are there any examples how to do that?
Beta Was this translation helpful? Give feedback.
All reactions