2

My approach to develop a multi-tenant i.e. Shared Database, Separate Schemas ideally on PostgreSQL. One database for all tenants, but one schema per tenant similar to django tenant schemas. Is there a guide or addon to achieve this on websauna?

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
lalilulelo
  • 85
  • 3
  • 9

1 Answers1

2

Here is what there is and there isn't

Already there

  • SQLAlchemy supports PostgreSQL tenancy. You can set this by overriding the database session factory when subclassing websauna.system.Initializer for your application. See configure_database that leads you to the path that allows to override create_dbsession. Your database session factory would look the properties of the HTTP request (domain) and configure session to point to the corresponding schema accordingly.

  • Add-on architecture that could provide a pluggable websauna.tenant addon

  • Theming: CSS and other assets (logo) can be customized by providing a site/base.html template that is a tenant aware. E.g. it injects css.html in <head> with the ability to define CSS filenames from the database. You would override the default site/base.html in the websauna.tenant addon.

Missing

Community
  • 1
  • 1
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • 2
    Alembic has some support for schmas: http://alembic.zzzcomputing.com/en/latest/ops.html?highlight=schema#alembic.operations.Operations.create_table.params.schema – Petri Jan 28 '17 at 13:54