I have a flask application and trying to make it multi-tenant using multiple schemas in a single database.
When an alteration needed to the database like adding a column, adding a table, and other alterations. I need to migrate through each to schemas. I changed my migrations/env.py like below
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
            config.get_section(config.config_ini_section),
            prefix='sqlalchemy.',
            poolclass=pool.NullPool)
# schemas = set([prototype_schema,None])
connection = engine.connect()
context.configure(
    connection=connection,
    target_metadata=target_metadata,
    include_schemas=True, #schemas,
    # include_object=include_schemas([None,prototype_schema])
    include_object=include_schemas([None])
)
try:
    domains = ['public', 'test', 'some_schema_name']
    for domain in domains:
        connection.execute('set search_path to "{}", public'.format(domain))
        with context.begin_transaction():
            context.run_migrations()
finally:
    connection.close()
The migrations are only affecting the first schema in the array. Here the public only gets migrated. I need to migrate across all schemas.