Generate migrations at path set by `config.paths["db/migrate"]` #27674

Merged
merged 1 commit into from Jan 17, 2017

Projects

None yet

6 participants

@kjg
Contributor
kjg commented Jan 13, 2017

Summary

Generate new database migrations at path set by config.paths["db/migrate"] instead of hardcoding the generations to db/migrate.

@kjg kjg Generate migrations at path set by `config.paths["db/migrate"]`
c942361
@kjg
Contributor
kjg commented Jan 16, 2017

@jeremy or @pixeltrix would you mind taking a quick look at this? Thanks!

@pixeltrix
Member

@kjg any reasons why you'd want to have migrations in a different place? Seems like a recipe for confusion in a project.

@kjg
Contributor
kjg commented Jan 17, 2017

@pixeltrix My use case is using activerecord via standalone-migrations to maintain db migrations/schemas for multiple applications all in one repo.

The location of migrations is already configurable https://github.com/rails/rails/blob/b70fc698e157f2a768ba42efac08c08f4786b01c/activerecord/lib/active_record/tasks/database_tasks.rb#L83

If we don't want it to be, maybe we should remove paths["db/migrate"] all together. If we're okay with keeping it configurable, let's make sure we're configurable everywhere that it matters.

@pixeltrix pixeltrix merged commit 4965fc1 into rails:master Jan 17, 2017

2 checks passed

codeclimate no new or fixed issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kjg
Contributor
kjg commented Jan 17, 2017

Thanks! Should I make a PR against 5-0-stable as well? I'd personally like to see this in 5.0.x if possible.

+
+ migration = "migration_in_custom_path"
+ run_generator [migration]
+ Rails.application.config.paths["db/migrate"] = old_paths
@simi
simi Jan 17, 2017 edited Contributor

Will be nice to wrap this into ensure block to cleanup changed setting also when something fails during this test.

@pixeltrix
pixeltrix Jan 17, 2017 Member

@simi thanks - fixed in a0e0505

@simi
simi Jan 17, 2017 Contributor

Same problem is in model_generator_test. I just mentioned that only once here. Sorry :(

@simi
simi Jan 17, 2017 Contributor

❤️

@pixeltrix
Member

@kjg backported in 3b2125e

@kjg kjg deleted the kjg:migration_generator_honor_path_config branch Jan 17, 2017
@rosenfeld
Contributor

This is awesome, thanks! I'll finally be able to get rid of this patch in active_record_migrations and fix it properly now.

@chris-roerig

This is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment