Best way to adapt an application for multi tenant?

Hello gentlemen, I have an application of a bubble instance and I would like to adapt it to the multi tenant. What would be the best way to carry out this adaptation?

1 Like

You’re saying right now the app is intended for 1 customer, but you want to expand it to multiple without them seeing each others data?

yea! the app is fully ready, so I would like to adapt it to multi-tenant

I have future plans as well for my app but I haven’t done it yet.

My plan is to add a data type called “Company” and add the Company field to literally every data type in my database. So a user has a Company field, Invoices have a Company field, everything. Then I make sure to make a Company, Run an API workflow to set my users to the new Company. Run an API to set everything’s Company.

Then in the privacy rules I setup the rule “When this Invoice’s Company is Current User’s Company” So a User can only see their own Company’s data.

I think that should work?

it might work, I’m a bit of a noob at bubble. How long do you think a freelancer would do this service for me??

Some people might do the privacy rule “When this Invoice’s Creator’s Company is Current User’s Company” then you don’t have to set the data type on all of them.

But my worry is what if the user get’s deleted now the data is an “orphan” and you wouldn’t know what Company it came from. Or if as a system admin you created some data for someone, now they wouldn’t be able to see it because you created it instead of them.

Yea I mean it’s good experience if you figure it out, what I described is my plan maybe someone has an easier way. It’s not too bad. How many data types do you have?

Some people might try to do the privacy rule that way, and Bubble would stop them dead in their tracks with this limitation. Just FYI.

2 Likes

Okay so it sounds like adding the field to every data type is the way to go anyways since it avoids this limitation. Thank you!

1 Like

I’m noob in Bubble, but for my knowledge in laravel, the best way to do this would be refactoring the workfows, so that the user registers in a single instance (company) and if the company is deleted, the user loses access to the platform because it was logged into the instance of the company in which he signed up. But I have no idea how to do it in Bubble.

In the case of php, it is not necessary to refactor the commands, just needing a modification in the database. For example, I have a food delivery system, I want to transfer it to the multitenant, it would only be necessary to create an adm login, and each adm would have its own instance that its users could register. But it seems that in Bubble the multi tenant is not as simple as Laravel

You’re using an external database it seems?

I see what you’re saying. Yea basically add a “Company” field to every single data type, then anywhere where a thing is created have it set it to the Current user’s Company. Then like I was saying earlier your privacy rules would be When This [thing]'s Company is Current User’s Company.

This topic was automatically closed after 70 days. New replies are no longer allowed.