Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mkrell's avatar
Level 1

How to handle multi-tenancy with multiple SQLite databases

Hi everyone.

I'm considering implementing multi-tenancy for my Laravel app using Turso, since to me that feels the easiest to manage and has built in backup systems (not to mention its free and very scaleable).

What I'm not sure about is how to roll out migrations across the app's databases cleanly. How would I handle a situation where the codebase is ahead of the migration script?

0 likes
3 replies
Tray2's avatar

I would suggest not using multiple databases, unless that is a legal requirement, one database can handle millions of rows, and instead of adding the complexity of database switching in your code, simply add a tenant_id column to your tables.

If you worry about performance, I would suggest moving to something like MySQL/MariaDB or PostgreSQL, and use partitioning per tenant. however I don't think that would be necessary at all, since it's likely you will not have that many rows of data in the beginning.

1 like
jlrdw's avatar

I agree and to add sqlite isn't good on heavy writes. You might want to consider PostgreSQL as @tray2 listed. But many do use MySql as well.

If you haven't yet perhaps take the multi tenant course here.

Spatie has options for single or multi databases also.

Please or to participate in this conversation.