Skip to content

Schema-level multi-tenancy with one common schema #1105

Discussion options

You must be logged in to vote

you would add another option handled by env.py that would also handle this special schema. if you had it explicitly in your models, then you'd bypass the logic that sets the schema, like:

from sqlalchemy import text

def run_migrations_online():
    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
    )

    special_schema = context.get_x_argument(as_dictionary=True).get("special_schema")
    current_tenant = context.get_x_argument(as_dictionary=True).get("tenant")

    if current_tenant is None and special_schema is None:
       raise Exception("tenant or special_schema expected")
    elif

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Gayathri-A-R
Comment options

@RicardoJDaleprane
Comment options

@zzzeek
Comment options

@RicardoJDaleprane
Comment options

@zzzeek
Comment options

Answer selected by Gayathri-A-R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants