Skip to content

Expert Answers to Your Magento, Shopify & Shopware Questions

Vendor-neutral, engineer-written explanations. Clear definitions first, then practical steps with real examples — no fluff.

Stagebit builds and maintains stores on Magento, Adobe Commerce, Shopify, Shopware, and Laravel, and this library holds the questions our own engineers get asked most often on each platform.

When should I move from a shared database to database-per-tenant?

SB
Written by Stagebit Engineering Team
Updated November 2026 4 min read Verified by engineers

Move when a specific requirement starts costing you more on a shared database than separate databases would. Customer-mandated data isolation and restoring a single tenant’s data are typical examples. The sections below separate real triggers from signals that only look like triggers.

Quick answer

Move to database-per-tenant in Laravel when a concrete requirement forces it. The four that qualify are contractual data isolation, per-tenant backup and restore, one tenant dominating database load, and per-tenant schema control. Tenant count alone is not a trigger. Without one of the four, stay on a shared database with tested tenant scoping, because the move adds provisioning, migration, and reporting work.

Which situations justify moving to database-per-tenant?

Four requirements justify moving to database-per-tenant, and a shared database handles each of them poorly.

  • Contractual or regulatory isolation. A tenant_id column gives logical separation. Some contracts and audits can ask for physical separation, meaning a dedicated database or region. A separate database supports that but does not guarantee compliance on its own.
  • Per-tenant backup, restore, and offboarding. Restoring one customer from a shared database means extracting and replaying rows. With a database per tenant, you restore one database and the other tenants stay untouched, as Microsoft’s SaaS tenancy patterns guide describes.
  • One tenant dominating load. One heavy tenant can slow every other tenant, which is the noisy neighbor problem. Check indexes, query plans, and read replicas first. A separate database on the same server still shares that server’s CPU, memory, and disk.
  • Per-tenant schema or release control. Some tenants need custom columns, a staged rollout, or a different retention policy. Separate databases allow that, but every schema difference adds migration work.

When should you stay on a shared database?

A shared database beats a separate database per tenant when none of the four triggers is real today. These situations also point to staying put:

  • You run many small tenants with similar usage, and cross-tenant reporting matters.
  • Your team cannot yet run per-tenant provisioning and migrations reliably.
  • The real problem is a missing index or a slow query, which splitting databases will not fix.
  • Your worry is a cross-tenant data leak. Tests that cover tenant scoping, including raw queries and queued jobs, address that risk directly.

No universal tenant count triggers the move. Any threshold quoted without your tenant size distribution and query patterns is a guess.

What does a Laravel database per tenant setup cost?

A Laravel database per tenant setup trades more operational work for less application code. Stancl’s tenancy documentation says the shared model, which it calls single-database tenancy, has lower devops complexity but larger code complexity. The table shows where the work moves.

ConcernShared databaseDatabase per tenant
Query scopingYou scope tenant queries by hand, and some third-party packages will not integrate.No manual scoping. The connection points at one tenant’s database.
Devops overheadLower. One database to run and monitor.Higher. Many databases to provision, migrate, monitor, and back up.
Infrastructure costGenerally the lowest per tenant, according to Microsoft’s guide.Generally higher, depending on whether databases share servers.
Schema migrationsOne run, one schema.One run per tenant database. Track status per tenant, because a failed run can leave tenants on different versions.
Cross-tenant reportingOne query.Queries across many databases, or a sync into a central store.

Two safeguards matter when you switch tenant databases. Resolve the tenant from a trusted source, such as the authenticated account or a verified domain, never from a value users can edit. In long-running queue workers, reset tenant context after every job so one tenant’s connection never reaches another tenant’s job. Both stancl/tenancy and spatie/laravel-multitenancy support single and multi-database setups, so check how your package handles queued jobs.

Moving existing data is a separate one-off project. Split shared reference tables, cross-tenant foreign keys, and tenant-owned files, verify each copy, and plan the cutover. The same Microsoft guide notes that switching models later is sometimes costly.

Laravel database per tenant routing: the app looks up a central tenants table, then connects to a shared or dedicated database

Can a Laravel app use both models?

Yes. A hybrid model keeps most tenants in a shared database and gives dedicated databases to tenants who need isolation or generate heavy load. A central tenants table can store each tenant’s database name. Microsoft’s guide lists hybrid tenancy as an available model, and it adds two data-access paths to test.

How should you decide?

Name the trigger before you plan a Laravel database per tenant migration. Write down which of the four applies and what the migration would cost. If you cannot name one, stay shared and tighten tenant scoping. For an existing application, Stagebit’s Laravel development services can review your data model and migration path.

Was this answer helpful?

Your feedback helps us improve our answers.

Still need help?

Questions about moving to database-per-tenant?

If you're weighing whether to move from a shared database to database-per-tenant, we're happy to walk through your isolation, restore, and migration needs and what your options are.

Talk to Laravel Experts