On Thu, Aug 30, 2018 at 7:11 AM, sector119 <sector...@gmail.com> wrote: > Mike, but in run_migrations_online() I use conn = > connection.execution_options(schema_translate_map={None: schema_name}) > But I get no schemas at resulting alembic/versions/file.py
can you share your env.py > > > среда, 29 августа 2018 г., 20:46:07 UTC+3 пользователь Mike Bayer написал: >> >> On Wed, Aug 29, 2018 at 5:12 AM, sector119 <sect...@gmail.com> wrote: >> > Hello >> > >> > I have N schemas with the same set of tables, 1 system schema with >> > users, >> > groups, ... tables and 6 schemas with streets, organizations, >> > transactions, >> > ... tables. >> > On those schemas tables I don't set __table_args__ = ({'schema': >> > SCHEMA},) >> > I just call dbsession.execute('SET search_path TO system, %s' % SCHEMA) >> > before sql queries. >> > >> > When I make some changes in my model structures I want to refactor table >> > in >> > all schemas using Alembic, how can I do that? >> > Maybe I can make some loop over my schemas somewhere? >> >> setting the search path is going to confuse SQLAlchemy's table >> reflection process, such that it assumes a Table of a certain schema >> does not require a "schema" argument, because it is already in the >> search path. >> >> Keep the search path set to "public", see >> >> http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#remote-schema-table-introspection-and-postgresql-search-path. >> There is an option to change this behavior mentioned in that >> section called postgresql_ignore_search_path, however it isn't >> guaranteed to suit all use cases. if that makes your case work, then >> that would be all you need. if not, then read on... >> >> For the officially supported way to do this, you want to have the >> explicit schema name inside the SQL - but this can be automated for a >> multi-tenancy application. Use the schema translation map feature: >> >> http://docs.sqlalchemy.org/en/latest/core/connections.html?highlight=execution_options#schema-translating. >> >> >> > >> > >> > Thanks >> > >> > -- >> > 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+...@googlegroups.com. >> > To post to this group, send email to sqlal...@googlegroups.com. >> > Visit this group at https://groups.google.com/group/sqlalchemy. >> > For more options, visit https://groups.google.com/d/optout. > > -- > 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. -- 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.