-
-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow multiple metadata objects for autogenerate #38
Comments
buddyteal7 wrote: It is very common to have multiple models and many tables. This feature seems quite important. I'm surprised more people haven't run in to this issue. |
Michael Bayer (@zzzeek) wrote: Currently I'm working around it roughly like this:
|
buddyteal7 wrote: I have a few questions about your work around: Are you using this work around in env.py and setting the value of target_metadata? Or is this used somewhere separate? Where is MetaData() being defined? t.tometadata(our_metadata) - not sure how this is working or what is actually getting set. I really like alembic and would love to get it working with multiple models. |
Michael Bayer (@zzzeek) wrote: this is in env.py. MetaData is defined within the application's model, then the local "our_metadata" is local to env.py. tometadata() is here: http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html?highlight=tometadata#sqlalchemy.schema.Table.tometadata . |
buddyteal7 wrote: Got it. Thanks for taking the time to clarify, much appreciated. |
Changes by Michael Bayer (@zzzeek):
|
Changes by Michael Bayer (@zzzeek):
|
Jon Skulski (@jskulski) wrote: Well one, thanks for alembic and SQLalchemy :) Two, this issue does seem very important. I'm exploring options at work (essentially SQLAlchemy vs Alembic) and this issue caused me to drop Alembic. I'm glad I found the work around and would suggest that it be placed in the tutorial. I'd imagine 99% of people want to use more than one object with alembic. Thanks! |
Jon Skulski (@jskulski) wrote: I'm a bit confused now. Because I tried with one of my models, and autogenerated against a blank sql database and it generated (seemingly) all the tables and columns I would need, even ones it has no relation too. Maybe it's the structure of the app I've inherited, and also my own confusion. Do we actually need to supply multiple metadata? |
Michael Bayer (@zzzeek) wrote: it's not a feature that comes up too much. most folks seem to have a single declarative Base for their app with a MetaData and that's it. in your case it depends on where you are storing all your Table objects - in one MetaData or several. |
Jon Skulski (@jskulski) wrote: Mike, Thank you for the reply. My comments were due to my misunderstanding. I was under the impression that you were using a per Table metadata. You can use the database metadata. So now I have
where I thought it had to be a specific model (target_metadata = model.metadata) and manually updated in step with code changes. Not the case! Hopefully, if anyone is suffering from the same delusions this will help. Thanks again! |
Dominik Czarnota (@disconnect3d) wrote: Could you guys at least add an example into tutorial that having more then one model one can do: models.py file:
env.py file:
? |
Michael Bayer (@zzzeek) wrote: @czarnot the models.py you illustrate there has just one MetaData object. http://alembic.readthedocs.org/en/latest/autogenerate.html illustrates this. |
Pankaj Lal wrote: Any chance, that this is going to be fixed any time soon. See my question here. http://stackoverflow.com/questions/38878887/handling-multiple-models-py-with-alembic |
Michael Bayer (@zzzeek) wrote: |
Michael Bayer (@zzzeek) wrote: Allow target_metadata to be a sequence The :paramref: Change-Id: I6485c05d68219ff7af1611b34550487d316e0242 → 7d5f6ea |
Changes by Michael Bayer (@zzzeek):
|
Migrated issue, originally created by Michael Bayer (@zzzeek)
The text was updated successfully, but these errors were encountered: