Search code examples
ruby-on-railsrubydirectorymigration

How to configure an extra/different migrations folder


A colleague and I are working in different projects that share some models. So, we are sharing the models through a git submodule.

Additionally, we'd like to be able to also share migrations:

In this way, my colleague's migrations would be in the folder db/migrate/other_db of my project.

How can I configure rails migrations to also run the migrations in this extra folder?


Solution

  • Update for Rails 5/6;

    Rails 5 recommends setting additional migration paths in your config/database.yml file. It's very easy, see this example;

    development:
      migrations_paths:
      - "db/migrate/other_db"
      - "db/migrate/something_else"
    

    ActiveRecord::Migrator.migrations_path= will be deprecated in Rails 6.