fullcube / loopback-component-migrate

Migration framework for loopback
43 stars 30 forks source link

Migrations based on environment #2

Open antonsamper opened 8 years ago

antonsamper commented 8 years ago

It would be really nice to be able to run migrations that apply to the current environment. The implementation could be similar to how Loopback currently deals with environment based configs. For example, if you only want to run a migration on stage you could name you file 0001-migration.stage.js or if you only wanted to run it on production, it would be 0001-migration.production.js.

sundeepgupta commented 7 years ago

@antonsamper I'm curious, why would you ever want to do this? I worked with Rails for a while and all migrations ran on all environments.

antonsamper commented 7 years ago

@sundeepgupta In general, I agree that migrations should run on all environments but it does depend on what the migration is doing. In my case I was using them to add data to the database. At the time, i was trying to setup up a fully functional dev environment (including dummy data) so that coworkers could get the app running without having to manually add anything. However, as this was dummy data, i didn't want it in production.

I know i could add environment checks in the migrations but i thought it could be quite nice to take the existing concept of appending the environment name to the filename.