I have created a good website system that meets the needs of a small niche market. I have been selling these sites over the past year, deploying copies of the software using Capistrano on my web server.
It seems to me that the only difference in these sites is a database, a CSS file and a small set of images used for graphic design of individual clients.
Everything else is exactly the same or should be ... Now that I have about 20 of these sites deployed, it is becoming increasingly difficult to maintain them all in the same code. And this problem will only get worse.
I think I need to reorganize this system so that I can use one set of deployed ruby codes, dynamically select the correct database, etc. at the URL of the incoming request.
There seem to be two ways to process the database:
- using multiple databases, one for each client
- using one database with client_id field in each table and additional client table
The multiple database method would be the easiest for me at the moment, since I would not have to reorganize every model in my application to add the client_id field to all CRUD operations.
However, it would not be easy to run "rake db: migrate" for tens or hundreds of different databases, every time I want to migrate a database. Obviously this can be done with a script, but it doesn't smell very good.
On the other hand, each customer will have 20K-50K items in the "items" table. I am worried about the speed of full-text search when the element table contains half a million or a million elements. Even with the index in the client_id field, I suspect that the search will be faster if the items are split into different client databases.
If someone has an informed opinion on the best way to solve this problem, I would really like to hear it. Thank you very much in advance...
- John