Sqlite DB per tenant

Hi,

Any one tried below solution locally or production in house ?

Please share your thoughts on the same.

2 Likes

Very disappointed that migrations were explicitly mentioned twice but no solution has been presented.

Analytics across all databases seems to be possible but “does make migrations a little more complicated” - without any further detail.

Otherwise I’m tempted to try this as I can see lots of benefits. From reduced risk of cross user data leaks to possibilities of data exports or replication on the DB level across devices…

This is a feature of Turso the company and libSQL the SQLite fork, but there is currently no Ruby driver for libSQL. Doing this with normal SQLite in a Rails app may be somewhat possible, but migrations are indeed the biggest sticking point. I hope to look into this more deeply in the coming weeks

3 Likes

I haven’t looked too closely at the rails source, but…

Can you not provide a line of code, e.g. User.select(User.primary_key.to_s).find(:all).to_a as your database location? In your migraton, you iterate through the array.