Forum: Ruby on Rails create database and run migration at run time

Posted by gagan sharma (gagansharma)
on 2012-09-28 10:39
Hi,

I have to create databases at run time depending on the name of the new
user's company and to run all the migrations for that new database.

for example: If a new user get registered and enter ABC as his company
name, then we will check if there is any existing user with same
company. If we dont have any user for that company then we have to
create a new Database and name it "ABC". After creating this new
Database we have to run all the migration for this new Database.

All this has to be done at run time and dynamicaly.


Thanks in advance for the solution.
Posted by Colin Law (Guest)
on 2012-09-29 18:48
(Received via mailing list)
On 28 September 2012 09:39, gagan sharma <lists@ruby-forum.com> wrote:
> Hi,
>
> I have to create databases at run time depending on the name of the new
> user's company and to run all the migrations for that new database.
>
> for example: If a new user get registered and enter ABC as his company
> name, then we will check if there is any existing user with same
> company. If we dont have any user for that company then we have to
> create a new Database and name it "ABC". After creating this new
> Database we have to run all the migration for this new Database.

Probably better not to do it this way.  Have just one database but add
fields to differentiate which records in each table belong to each
user.  The user will not be able to tell the difference between that
and your suggested solution.

Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.