Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f5ddf817
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,发现更多精彩内容 >>
提交
f5ddf817
编写于
10月 30, 2018
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Exercise HABTM fixtures with foreign key constraints
上级
ad3669ee
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
45 deletion
+52
-45
activerecord/test/models/parrot.rb
activerecord/test/models/parrot.rb
+6
-0
activerecord/test/schema/schema.rb
activerecord/test/schema/schema.rb
+46
-45
未找到文件。
activerecord/test/models/parrot.rb
浏览文件 @
f5ddf817
...
...
@@ -20,6 +20,12 @@ def cancel_save_callback_method
def
increment_updated_count
self
.
updated_count
+=
1
end
def
self
.
delete_all
(
*
)
connection
.
delete
(
"DELETE FROM parrots_pirates"
)
connection
.
delete
(
"DELETE FROM parrots_treasures"
)
super
end
end
class
LiveParrot
<
Parrot
...
...
activerecord/test/schema/schema.rb
浏览文件 @
f5ddf817
...
...
@@ -601,33 +601,55 @@
t
.
integer
:non_poly_two_id
end
create_table
:parrots
,
force:
true
do
|
t
|
t
.
column
:name
,
:string
t
.
column
:color
,
:string
t
.
column
:parrot_sti_class
,
:string
t
.
column
:killer_id
,
:integer
t
.
column
:updated_count
,
:integer
,
default:
0
if
subsecond_precision_supported?
t
.
column
:created_at
,
:datetime
,
precision:
0
t
.
column
:created_on
,
:datetime
,
precision:
0
t
.
column
:updated_at
,
:datetime
,
precision:
0
t
.
column
:updated_on
,
:datetime
,
precision:
0
else
t
.
column
:created_at
,
:datetime
t
.
column
:created_on
,
:datetime
t
.
column
:updated_at
,
:datetime
t
.
column
:updated_on
,
:datetime
disable_referential_integrity
do
create_table
:parrots
,
force: :cascade
do
|
t
|
t
.
string
:name
t
.
string
:color
t
.
string
:parrot_sti_class
t
.
integer
:killer_id
t
.
integer
:updated_count
,
:integer
,
default:
0
if
subsecond_precision_supported?
t
.
datetime
:created_at
,
precision:
0
t
.
datetime
:created_on
,
precision:
0
t
.
datetime
:updated_at
,
precision:
0
t
.
datetime
:updated_on
,
precision:
0
else
t
.
datetime
:created_at
t
.
datetime
:created_on
t
.
datetime
:updated_at
t
.
datetime
:updated_on
end
end
end
create_table
:parrots_pirates
,
id:
false
,
force:
true
do
|
t
|
t
.
column
:parrot_id
,
:integer
t
.
column
:pirate_id
,
:integer
end
create_table
:pirates
,
force: :cascade
do
|
t
|
t
.
string
:catchphrase
t
.
integer
:parrot_id
t
.
integer
:non_validated_parrot_id
if
subsecond_precision_supported?
t
.
datetime
:created_on
,
precision:
6
t
.
datetime
:updated_on
,
precision:
6
else
t
.
datetime
:created_on
t
.
datetime
:updated_on
end
end
create_table
:parrots_treasures
,
id:
false
,
force:
true
do
|
t
|
t
.
column
:parrot_id
,
:integer
t
.
column
:treasure_id
,
:integer
create_table
:treasures
,
force: :cascade
do
|
t
|
t
.
string
:name
t
.
string
:type
t
.
references
:looter
,
polymorphic:
true
t
.
references
:ship
end
create_table
:parrots_pirates
,
id:
false
,
force:
true
do
|
t
|
t
.
references
:parrot
,
foreign_key:
true
t
.
references
:pirate
,
foreign_key:
true
end
create_table
:parrots_treasures
,
id:
false
,
force:
true
do
|
t
|
t
.
references
:parrot
,
foreign_key:
true
t
.
references
:treasure
,
foreign_key:
true
end
end
create_table
:people
,
force:
true
do
|
t
|
...
...
@@ -673,19 +695,6 @@
t
.
column
:rainbow_color
,
:string
end
create_table
:pirates
,
force:
true
do
|
t
|
t
.
column
:catchphrase
,
:string
t
.
column
:parrot_id
,
:integer
t
.
integer
:non_validated_parrot_id
if
subsecond_precision_supported?
t
.
column
:created_on
,
:datetime
,
precision:
6
t
.
column
:updated_on
,
:datetime
,
precision:
6
else
t
.
column
:created_on
,
:datetime
t
.
column
:updated_on
,
:datetime
end
end
create_table
:posts
,
force:
true
do
|
t
|
t
.
references
:author
t
.
string
:title
,
null:
false
...
...
@@ -916,14 +925,6 @@
t
.
datetime
:updated_at
end
create_table
:treasures
,
force:
true
do
|
t
|
t
.
column
:name
,
:string
t
.
column
:type
,
:string
t
.
column
:looter_id
,
:integer
t
.
column
:looter_type
,
:string
t
.
belongs_to
:ship
end
create_table
:tuning_pegs
,
force:
true
do
|
t
|
t
.
integer
:guitar_id
t
.
float
:pitch
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录