Skip to content

Commit

Permalink
some updates to the commit for multi-tenant I just did
Browse files Browse the repository at this point in the history
Change-Id: I5e9c03697af5d65f68c37bf4afd6caaf73ce270a
  • Loading branch information
zzzeek committed Aug 19, 2024
1 parent 858abd3 commit 30292b3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions docs/build/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,19 @@ the approach must involve running Alembic multiple times against different
database URLs.

One common approach to multi-tenancy, particularly on the PostgreSQL database,
is to install tenants within **individual PostgreSQL schemas**. When using
PostgreSQL's schemas, a special variable ``search_path`` is offered that is
intended to assist with targeting of different schemas.

When using MySQL or MariaDB databases, a similar command is available at the
SQL level called the``use`` command. This command may be used in a similar
fashion as that of PostgreSQL's ``search_path`` variable to achieve a similar
effect.
is to install tenants within **individual PostgreSQL schemas**; similarly
when using MySQL/MariaDB, **individual MySQL/MariaDB databases** are addressed
in the same way as "schemas" on PostgreSQL.

When using PostgreSQL's schemas, a special variable ``search_path`` is offered
that is intended to assist with targeting of different schemas. When using
MySQL or MariaDB databases, a similar command is available at the SQL level
called the ``USE`` command. This command may be used in a similar fashion as
that of PostgreSQL's ``search_path`` variable to achieve a similar effect.

Overall, this recipe can be used on **any database that supports runtime
modification of the current "tenant" via SQL commands on a particular
connection**.

.. note:: SQLAlchemy includes a system of directing a common set of
``Table`` metadata to many schemas called `schema_translate_map <https://docs.sqlalchemy.org/core/connections.html#translation-of-schema-names>`_. Alembic at the time
Expand Down

0 comments on commit 30292b3

Please sign in to comment.