On Sun, Feb 3, 2019 at 6:00 PM Mike Bayer <clas...@zzzcomputing.com> wrote:
> > > On Sun, Feb 3, 2019, 6:18 AM Anders Steinlein <and...@e5r.no wrote: > >> >> Is there a way to dynamically set up the table for a particular >> declarative model, i.e. based on the bind? The point is that we'd like all >> code to still use the same and only model class, and just have conditionals >> in the code where appropriate for the differences in columns. >> > > > There's not really a way to do that because mappings create a considerable > amount of permanent state against the structure of tables. I would > approach these as online migrations where you use an expand / contract > model, that is, new columns and tables only within "expand", then once all > schemas are migrated, upgrade the code, then run "contract" to remove old > tables and columns no longer needed. > Right, that's the alternative I was considering. How would I go about adding columns to the model that doesn't necessarily exist in all cases? Using deferred() on the columns, I guess? Best, Anders -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.