In a Ruby on Rails project, all migration files generate into the same
directory 'db/migrate'. It's enough for simple projects, but not
that good for large modulized projects. It is inconvenient to review
thousands of files in the same directory for one project.
It looks like:
<img
src="https://ruby-china-files.b0.upaiyun.com/photo/2014/1c58bc1196dfe04f6e4a1f6819ce2549.png"
/>
Since MVC directories are modular, the migration directory should the
same. It's expected to be structured and clear. That's the reason I
release the gem <a
href="https://github.com/swordray/modular_migration">modular_migration</a>.
Just include it in your Gemfile:
<code>gem 'modular_migration'</code>
Using Rails generator as usual:
<code>$ rails generate model Core::User name:string
invoke active_record
create app/models/core/user.rb
create app/models/core.rb
create db/migrate/core/user/20140324105328_create_core_users.rb
</code>
It will look like:
<img
src="https://ruby-china-files.b0.upaiyun.com/photo/2014/b881fc62be420c8b81645dcdad40416d.png"
/>
Source code and issue tracking: <a
href="https://github.com/swordray/modular_migration">https://github.com/swordray/modular_migration</a>
Welcome to star, fork and pull request at GitHub.