Liking cljdoc? Tell your friends :D

wagoe.tenant.shell.tenant-migrations

Per-tenant schema migration fan-out.

The platform migrate runs the migration set against the public schema. Each tenant lives in its own tenant_<slug> schema, so the same migrations must also run inside every tenant schema — otherwise a schema change lands in public but not in existing tenants, and queries executed under the tenant search_path fail with missing relation/column errors (the drift this fixes).

Each tenant run pins search_path on a connection of its own to the tenant schema, so migratus creates its own schema_migrations ledger inside that schema and applies DDL there.

Because migrations run once per tenant schema, tenant-run migrations must be idempotent / tenant-scoped.

Per-tenant schema migration fan-out.

The platform `migrate` runs the migration set against the public schema. Each
tenant lives in its own `tenant_<slug>` schema, so the same migrations must
also run inside every tenant schema — otherwise a schema change lands in
public but not in existing tenants, and queries executed under the tenant
search_path fail with missing relation/column errors (the drift this fixes).

Each tenant run pins search_path on a connection of its own to the tenant
schema, so migratus creates its own `schema_migrations` ledger inside that
schema and applies DDL there.

Because migrations run once per tenant schema, tenant-run migrations must be
idempotent / tenant-scoped.
raw docstring

default-tenant-migration-dirclj

Classpath-relative directory holding tenant-scoped migrations — the set that runs inside every tenant schema (must only touch tenant-scoped tables). Kept separate from the public migrations/ set, which runs once against public.

Classpath-relative directory holding tenant-scoped migrations — the set that
runs inside every tenant schema (must only touch tenant-scoped tables). Kept
separate from the public `migrations/` set, which runs once against public.
sourceraw docstring

migrate-all-tenants!clj

(migrate-all-tenants! ctx schemas)
(migrate-all-tenants! ctx schemas migration-dir)

Fan out pending tenant-scoped migrations across the given tenant schemas.

Continues past a failing schema so one bad tenant does not block the rest; returns {:schemas-migrated [...] :errors {schema-name message}}. Callers get the schema list from provisioning/list-tenant-schemas (kept out of this ns to avoid a dependency cycle with provisioning).

Fan out pending tenant-scoped migrations across the given tenant schemas.

Continues past a failing schema so one bad tenant does not block the rest;
returns {:schemas-migrated [...] :errors {schema-name message}}. Callers get
the schema list from `provisioning/list-tenant-schemas` (kept out of this ns
to avoid a dependency cycle with provisioning).
sourceraw docstring

migrate-tenant!clj

(migrate-tenant! ctx schema-name)
(migrate-tenant! ctx schema-name migration-dir)

Run all pending tenant-scoped migrations inside one tenant schema of the database ctx (the boot :wagoe/db-context) is connected to. migration-dir is a classpath-relative tenant migration directory, or a vector of them; by default tenant-migration-dirs of the libraries ctx names under :enabled-libraries, which the system's :wagoe/db-context carries; without them, every library's. Throws on a malformed schema name.

Runs on a connection outside the pool, so its session settings close with it instead of reaching the application's next query. No statement timeout: migrations run long (BOU-658). search_path is the tenant schema only: with a ,public fallback migratus's CREATE TABLE IF NOT EXISTS schema_migrations resolves to public.schema_migrations, every tenant shares that ledger, and the second skips migrations it never ran. So migrations run here may only reference tables in the tenant schema.

Run all pending tenant-scoped migrations inside one tenant schema of the
database `ctx` (the boot `:wagoe/db-context`) is connected to.
`migration-dir` is a classpath-relative tenant migration directory, or a
vector of them; by default `tenant-migration-dirs` of the libraries `ctx`
names under `:enabled-libraries`, which the system's `:wagoe/db-context`
carries; without them, every library's. Throws on a malformed schema name.

Runs on a connection outside the pool, so its session settings close with it
instead of reaching the application's next query. No statement timeout:
migrations run long (BOU-658). search_path is the tenant schema only: with a
`,public` fallback migratus's `CREATE TABLE IF NOT EXISTS schema_migrations`
resolves to `public.schema_migrations`, every tenant shares that ledger, and
the second skips migrations it never ran. So migrations run here may only
reference tables in the tenant schema.
sourceraw docstring

tenant-migration-dirsclj

(tenant-migration-dirs enabled-libs)

What a tenant schema runs: the application's migrations-tenant/, then the tenant directories the libraries on the classpath ship — given enabled-libs, only those of modules switched on, as migrate up does. They share one ledger per schema, so two migrations with one id are refused.

What a tenant schema runs: the application's `migrations-tenant/`, then the
tenant directories the libraries on the classpath ship — given
`enabled-libs`, only those of modules switched on, as `migrate up` does.
They share one ledger per schema, so two migrations with one id are refused.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close