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?
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.