Security release
This release stops a tenant named $user from using another schema (GHSA-rh58-8mmc-gcfw, medium).
In a search_path, PostgreSQL replaces $user, even when quoted, with the schema named after the current database role. A tenant created or renamed as $user therefore ran its migrations and queries against that schema, which could be another tenant's, even with TENANT_REJECT_EXISTING_SCHEMA on.
Affected: all versions before 4.0.7. All users should upgrade, especially projects where users choose their tenant's schema name.
See the advisory for full details, workarounds and how to check for an existing $user tenant.
Upgrade notes
$user(in any case) is no longer a valid schema name. A$usertenant can no longer be switched to, and stopsmigrate_schemasat that tenant; see the advisory for how to remove it.$userinPG_EXTRA_SEARCH_PATHSorPUBLIC_SCHEMA_NAMEis now rejected too.TenantMixin.create_schema()now returns the connection to the public schema when it fails, as it already did on success. A failed tenant create now removes the tenant's row and raises the original error.