未验证 提交 8a0194f1 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #33994 from gmcgibbon/rails_g_model_migrations_paths

Add migrations_paths option to model generator
......@@ -14,6 +14,7 @@ class ModelGenerator < Base # :nodoc:
class_option :parent, type: :string, desc: "The parent class for the generated model"
class_option :indexes, type: :boolean, default: true, desc: "Add indexes for references and belongs_to columns"
class_option :primary_key_type, type: :string, desc: "The type for primary key"
class_option :migrations_paths, type: :string, desc: "The migration path for your generated migrations. If this is not set it will default to db/migrate"
# creates the migration file for the model.
def create_migration_file
......
* 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
......
......@@ -392,6 +392,15 @@ def test_add_uuid_to_create_table_migration
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}"]
......
......@@ -476,6 +476,12 @@ def test_scaffold_generator_belongs_to
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"]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册