I’m writing a SaaS model application.
My application database consist of two logic parts:
- application tables – such as user, roles…
- user-defined tables (he can generate them from UI level) that can be different for each application instance
All tables are created by rails migrations mechanism.
I would like to put user-defined tables in another directory:
- db/migrations – application tables
- db/migrations/custom – tables generated by user
so I can do svn:ignore on db/migrations/custom, and when I do updates of my app on clients servers it would only update application tables migrations.
Is there any way to achieve this in rails?
@Vasily thank’s for your response. After reading it and couple more questions from stackoverflow I came up with this solution:
Since I write my own generator to create user tables I included Rails::Generators::Migration in it so I can override next_migration_number method like this:
Now all migrations generated by user are created in db/migrations/custom directory.
Then I wrote normal rails migration that executes all migrations from db/migrations/custom directory:
After user creates custom table i call this migration with this code: