Re: Autogenerate with Multi-Tenant

2020-03-20 Thread Brian Hill
That works! Thank you. Brian On Friday, March 20, 2020 at 12:11:21 PM UTC-4, Mike Bayer wrote: > > OK one more addition to the recipe, please do this: > > DB_SCHEMA = "my_foo_schema" > > with connectable.connect() as connection: > connection.execute(f'create schema if not exists

Re: Autogenerate with Multi-Tenant

2020-03-20 Thread Mike Bayer
OK one more addition to the recipe, please do this: DB_SCHEMA = "my_foo_schema" with connectable.connect() as connection: connection.execute(f'create schema if not exists {DB_SCHEMA}') connection.execute(f'set search_path to {DB_SCHEMA}') connection.dialect.default_schema_name = DB_SCHEMA

Re: Autogenerate with Multi-Tenant

2020-03-20 Thread Brian Hill
this is what i tried but it generated the whole schema: . with connectable.connect() as connection: connection.execute(f'create schema if not exists {DB_SCHEMA}') connection.execute(f'set search_path to {DB_SCHEMA}') context.configure( connection=connection, target_metadata=metadata, ) with

Re: Autogenerate with Multi-Tenant

2020-03-20 Thread Mike Bayer
I just realized that you really dont need to even use schema_translate_map at all here. If you use a completely straight env.py, and simply set search_path=SCHEMA, you should be able to run Alembic in entirely "schemaless" mode; don't include schemas anywhere nor would you need to set it for