We have a set of Ruby on Rails applications that shares user logins, so we put that table in a database and connect to it from each application.
If an app needs to add a column to the shared table, you can create a migration that accesses that other database.
First, create an entry in your
database.yml file (we name ours “user_development”, etc.).
Then, establish that connection in your database migration and do your migration stuff:
This has the benefit of keeping all the migrations local to the app they’re needed for, but it stores the schema of the users table in the users database where it belongs.
4 Comments to “Running rails migrations in other databases”
We live and work in Kansas City, USA.
We're passionate about helping small businesses succeed and want to help you use technology to get more done.
From server, desktop, network management to programming custom web applications in Ruby on Rails, we're here to lend a hand.
Contact us if you have any questions!