diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-09-27 11:26:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 11:26:49 -0400 |
commit | 8a0194f1514fc2374b18db909f78f733ba0857b9 (patch) | |
tree | 7e644c6581425760f859a49bf207e13ed56677a3 /railties | |
parent | 1930d22936c3bfb883dd4b46173bb902db17bb50 (diff) | |
parent | 77aaeced89cb84404cf69f8b23834520de3214a9 (diff) | |
download | rails-8a0194f1514fc2374b18db909f78f733ba0857b9.tar.gz rails-8a0194f1514fc2374b18db909f78f733ba0857b9.tar.bz2 rails-8a0194f1514fc2374b18db909f78f733ba0857b9.zip |
Merge pull request #33994 from gmcgibbon/rails_g_model_migrations_paths
Add migrations_paths option to model generator
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 16 | ||||
-rw-r--r-- | railties/test/generators/model_generator_test.rb | 9 | ||||
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 6 |
3 files changed, 31 insertions, 0 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 4342cf6968..a839f80eb3 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,19 @@ +* Adds an option to the model 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 model Room capacity:integer --migrations-paths=db/kingston_migrate + invoke active_record + create db/kingston_migrate/20180830151055_create_rooms.rb + ``` + + Because rails scaffolding uses the model generator, you can + also specify migrations paths with the scaffold generator. + + *Gannon McGibbon* + * Raise an error when "recyclable cache keys" are being used by a cache store that does not explicitly support it. Custom cache keys that do support this feature can bypass this error by implementing the `supports_cache_versioning?` method on their diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index 7febdfae96..5a0c2f74c7 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -392,6 +392,15 @@ class ModelGeneratorTest < Rails::Generators::TestCase end end + def test_migrations_paths_puts_migrations_in_that_folder + run_generator ["account", "--migrations_paths=db/test_migrate"] + assert_migration "db/test_migrate/create_accounts.rb" do |content| + assert_method :change, content do |change| + assert_match(/create_table :accounts/, change) + end + end + end + def test_required_belongs_to_adds_required_association run_generator ["account", "supplier:references{required}"] diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index e90834bc2b..dbcf49290e 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -476,6 +476,12 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end end + def test_scaffold_generator_migrations_paths + run_generator ["posts", "--migrations-paths=db/kingston_migrate"] + + assert_migration "db/kingston_migrate/create_posts.rb" + end + def test_scaffold_generator_password_digest run_generator ["user", "name", "password:digest"] |