I originally wrote a Ruby on Rails application for one client. Now I am changing it so that it can be used for different clients. My ultimate goal is that some users (not me) can click a button and create a new project. Then all necessary changes (new schema, new tables, code processing) are generated without the need to edit the database.yml file or add new schema definitions. I am currently using SCOPED access. So I have a project model, and other related models have a project_id column.
I looked at other posts regarding multi-tenant applications in Rails. Many people seem to suggest creating a different scheme for each new client in Postgres. However, for me it is not very useful for the new client to have a different scheme in terms of data model. Each client will have the same tables, rows, columns, etc.
My vision of each client is that in my production database there is a table of different projects / clients. And each of these tables refers to a set of tables that are almost the same for different data. In other words, a table of tables. Or, in other words, the first table will display a different data set for each client that has the same structure.
I explain my vision, similar to how Postgres implements different "schemes"? Does this look like nested tables? Or should Postgres still request all the information in the database? I am not currently using Postgres, but I would like to know if this matches the design. If you know a database software that works with Rails that suits my needs, let me know.
I am currently using scopes to run multiple tenant applications, but it does not feel scalable or clean. However, it is very easy for a non-technical user to create a new project if I give them fill-in information. Do you know if this is possible when defining a Postgres multiple schema so that it works automatically after a user clicks a button? And I would prefer it to be handled by Rails rather than an external script, if possible? (consult anyway)
Most importantly, do you recommend any plugins or should I adopt a different structure for this task? I found that Rails is limited in some cases of abstraction, as mentioned above, and this is the first time that I have encountered the problem of scaling Rails.
Any advice related to multi-tenant applications or my situation is welcome. Any questions for clarification or additional advice are also welcome.
Thanks, --Dave
ruby-on-rails postgresql ruby-on-rails-3 database-design multi-tenant
David groff
source share