Automation?
In theory, it should be possible to create a tool that facilitates the implementation of this complex operation (the transition from one tenant to multiple tenant). However, I do not think that such a tool exists, given the limited audience of such a product. It would be very nice if you surfaced.
Manual Conversion Ideas
Start by developing a new multi-tenant database schema. (This means combining all the database schemas with one tenant with any shared schemas that you have). I would like to make it as if it was designed without any outdated considerations.
You obviously need a Tenant table that many of your existing tenant tables with the Tenant_id column will have to Tenant_id . For example, a user table will require that it uniquely associate users with the tenant.
In the case of a simple Products table (with Product_id as the primary key), it should be possible to add the Tenant_id column, resulting in a table with a composite key ( Tenant_id and Product_id ). But if you wrote the application from scratch, I believe that the Product table without a reference to the tenant is the right way. It also allows tenants to share products rather than add duplicates. Since one tenant can have products with Product_id 1,2,3 and 1,2 more, you cannot simply join the tables, because you cannot use the same identifier twice - you need unique primary key values. One way to solve this problem is to write a program (in Java or another high-level language) that reads all the data from the tenant's database into objects in memory, and then writes the data to a circuit with several tenants. The process is repeated for the next tenant database, etc. That way you will have Product_id values ββ1,2,3,4,5. A quick, dirty way would be to add a number, say 1000, 2000, and so on, to all the identifier values ββin each circuit and just cross your fingers so that there are no conflicts.
The code that communicates with the database
You will need to rewrite most of the database queries in order to take into account the fact that the database is now multi-user. This is a difficult task, especially considering the consequences of introducing an error that allows one tenant to bother with other data of the tenant. However, some methods may make this task easier. For example, the Tenant View Filter can significantly reduce the amount of work required.
Limit the number of tenants
I have never seen a recommendation to limit the number of tenants in a multi-tenant structure. On the contrary, the strength of the multi-user approach is its scalability. Today, you can easily create database server clusters or use cloud solutions to add additional hardware if necessary.
Interesting links