diff options
author | Eileen Uchitelle <eileencodes@gmail.com> | 2018-08-30 11:18:40 -0400 |
---|---|---|
committer | Eileen Uchitelle <eileencodes@gmail.com> | 2018-08-30 11:18:40 -0400 |
commit | b551a707552598bd0134a6ebecb076f0f7edeaa1 (patch) | |
tree | 6537d9f3a1b7939833849dd539474aa66aa8e8bd /railties | |
parent | 3d2caab7dc92a13d4dd369678d5b4ce659df8e52 (diff) | |
download | rails-b551a707552598bd0134a6ebecb076f0f7edeaa1.tar.gz rails-b551a707552598bd0134a6ebecb076f0f7edeaa1.tar.bz2 rails-b551a707552598bd0134a6ebecb076f0f7edeaa1.zip |
Add migrations_paths option to migration generator
Adds an option to the migration generator to allow setting the
migrations paths for that migration. This is useful for applications
that use multiple databases and put migrations per database in their own
directories.
```
bin/rails g migration CreateHouses address:string --migrations-paths=db/kingston_migrate
invoke active_record
create db/kingston_migrate/20180830151055_create_houses.rb
```
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 15 | ||||
-rw-r--r-- | railties/test/generators/migration_generator_test.rb | 9 |
2 files changed, 24 insertions, 0 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 2a8882171f..b855fb7da2 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,18 @@ +* Add `--migrations_paths` option to migration generator. + + If you're using multiple databases and have a folder for each database + for migrations (ex db/migrate and db/new_db_migrate) you can now pass the + `--migrations_paths` option to the generator to make sure the the migration + is inserted into the correct folder. + + ``` + rails g migration CreateHouses --migrations_paths=db/kingston_migrate + invoke active_record + create db/kingston_migrate/20180830151055_create_houses.rb + ``` + + *Eileen M. Uchitelle* + * Deprecate `rake routes` in favor of `rails routes`. *Yuji Yaginuma* diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb index 657a56354b..5c57d607fc 100644 --- a/railties/test/generators/migration_generator_test.rb +++ b/railties/test/generators/migration_generator_test.rb @@ -254,6 +254,15 @@ class MigrationGeneratorTest < Rails::Generators::TestCase end end + def test_migrations_paths_puts_migrations_in_that_folder + run_generator ["create_books", "--migrations_paths=db/test_migrate"] + assert_migration "db/test_migrate/create_books.rb" do |content| + assert_method :change, content do |change| + assert_match(/create_table :books/, change) + end + end + end + def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove_or_create migration = "delete_books" run_generator [migration, "title:string", "content:text"] |