From 30292b38b73d94d4cea743137c4261cf9a305e1f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 19 Aug 2024 11:13:27 -0400 Subject: [PATCH] some updates to the commit for multi-tenant I just did Change-Id: I5e9c03697af5d65f68c37bf4afd6caaf73ce270a --- docs/build/cookbook.rst | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/build/cookbook.rst b/docs/build/cookbook.rst index a9121730..ce5fb543 100644 --- a/docs/build/cookbook.rst +++ b/docs/build/cookbook.rst @@ -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 `_. Alembic at the time -- 2.47.2