I am working on a Multi-tenant Ruby on Rails App along with another developer. I pulled his branch and received new migration files. I ran rake db:migrate. I visit the index of that controller and I get the undefined error.
After some research I understood that I ran migration after I created my Tenant. (Reference: PG::UndefinedTable: ERROR: relation "..." does not exist) and I also understand that rake db:reset resolved this issue in development. But doing a reset purges my data which I am fine with in development.
My concern is, how does this work in production? When I release to production... does that mean that for existing tenants I cannot run migrations and ship new features?
Is there a permanent solution to this?
If you set the following line in your config file,
config.tenant_names = lambda{ Customer.pluck(:tenant_name) }
When you run rake db:migrate
all the existing tenant's schema will be migrated.