Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8a0194f1
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8a0194f1
编写于
9月 27, 2018
作者:
R
Rafael França
提交者:
GitHub
9月 27, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #33994 from gmcgibbon/rails_g_model_migrations_paths
Add migrations_paths option to model generator
上级
1930d229
77aaeced
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
0 deletion
+32
-0
activerecord/lib/rails/generators/active_record/model/model_generator.rb
...b/rails/generators/active_record/model/model_generator.rb
+1
-0
railties/CHANGELOG.md
railties/CHANGELOG.md
+16
-0
railties/test/generators/model_generator_test.rb
railties/test/generators/model_generator_test.rb
+9
-0
railties/test/generators/scaffold_generator_test.rb
railties/test/generators/scaffold_generator_test.rb
+6
-0
未找到文件。
activerecord/lib/rails/generators/active_record/model/model_generator.rb
浏览文件 @
8a0194f1
...
...
@@ -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
...
...
railties/CHANGELOG.md
浏览文件 @
8a0194f1
*
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
...
...
railties/test/generators/model_generator_test.rb
浏览文件 @
8a0194f1
...
...
@@ -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}"
]
...
...
railties/test/generators/scaffold_generator_test.rb
浏览文件 @
8a0194f1
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录