Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
7a15e282
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,发现更多精彩内容 >>
提交
7a15e282
编写于
7月 07, 2016
作者:
V
Vipul A M
提交者:
GitHub
7月 07, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #25745 from alexcameron89/schema_statements
[ci skip] Update documentation in AR SchemaStatements
上级
24f04b66
ffffecac
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
12 deletion
+12
-12
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
..._record/connection_adapters/abstract/schema_statements.rb
+12
-12
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
浏览文件 @
7a15e282
...
...
@@ -179,7 +179,7 @@ def primary_key(table_name)
# A Symbol can be used to specify the type of the generated primary key column.
# [<tt>:primary_key</tt>]
# The name of the primary key, if one is to be added automatically.
# Defaults to +id+. If <tt>:id</tt> is false this option is ignored.
# Defaults to +id+. If <tt>:id</tt> is false
, then
this option is ignored.
#
# Note that Active Record models will automatically detect their
# primary key. This can be avoided by using
...
...
@@ -305,9 +305,9 @@ def create_table(table_name, comment: nil, **options)
# # Creates a table called 'assemblies_parts' with no id.
# create_join_table(:assemblies, :parts)
#
# You can pass a
+options+ has
h can include the following keys:
# You can pass a
n +options+ hash whic
h can include the following keys:
# [<tt>:table_name</tt>]
# Sets the table name
overriding the default
# Sets the table name
, overriding the default.
# [<tt>:column_options</tt>]
# Any extra options you want appended to the columns definition.
# [<tt>:options</tt>]
...
...
@@ -433,7 +433,7 @@ def drop_join_table(table_1, table_2, options = {})
# t.remove_index :company_id
# end
#
# See also Table for details on all of the various column transformation.
# See also Table for details on all of the various column transformation
s
.
def
change_table
(
table_name
,
options
=
{})
if
supports_bulk_alter?
&&
options
[
:bulk
]
recorder
=
ActiveRecord
::
Migration
::
CommandRecorder
.
new
(
self
)
...
...
@@ -483,10 +483,10 @@ def drop_table(table_name, options = {})
#
# Available options are (none of these exists by default):
# * <tt>:limit</tt> -
# Requests a maximum column length. This is number of characters for a <tt>:string</tt> column
# Requests a maximum column length. This is
the
number of characters for a <tt>:string</tt> column
# and number of bytes for <tt>:text</tt>, <tt>:binary</tt> and <tt>:integer</tt> columns.
# * <tt>:default</tt> -
# The column's default value. Use
nil for NULL
.
# The column's default value. Use
+nil+ for +NULL+
.
# * <tt>:null</tt> -
# Allows or disallows +NULL+ values in the column. This option could
# have been named <tt>:null_allowed</tt>.
...
...
@@ -495,7 +495,7 @@ def drop_table(table_name, options = {})
# * <tt>:scale</tt> -
# Specifies the scale for the <tt>:decimal</tt> and <tt>:numeric</tt> columns.
#
# Note: The precision is the total number of significant digits
# Note: The precision is the total number of significant digits
,
# and the scale is the number of digits that can be stored following
# the decimal point. For example, the number 123.45 has a precision of 5
# and a scale of 2. A decimal with a precision of 5 and a scale of 2 can
...
...
@@ -564,7 +564,7 @@ def remove_columns(table_name, *column_names)
#
# The +type+ and +options+ parameters will be ignored if present. It can be helpful
# to provide these in a migration's +change+ method so it can be reverted.
# In that case, +type+ and +options+ will be used by add_column.
# In that case, +type+ and +options+ will be used by
#
add_column.
def
remove_column
(
table_name
,
column_name
,
type
=
nil
,
options
=
{})
execute
"ALTER TABLE
#{
quote_table_name
(
table_name
)
}
DROP
#{
quote_column_name
(
column_name
)
}
"
end
...
...
@@ -952,13 +952,13 @@ def remove_foreign_key(from_table, options_or_to_table = {})
# Checks to see if a foreign key exists on a table for a given foreign key definition.
#
# # Check
a foreign key exists
# # Check
s to see if a foreign key exists.
# foreign_key_exists?(:accounts, :branches)
#
# # Check
a foreign key on a specified column exists
# # Check
s to see if a foreign key on a specified column exists.
# foreign_key_exists?(:accounts, column: :owner_id)
#
# # Check
a foreign key with a custom name exists
# # Check
s to see if a foreign key with a custom name exists.
# foreign_key_exists?(:accounts, name: "special_fk_name")
#
def
foreign_key_exists?
(
from_table
,
options_or_to_table
=
{})
...
...
@@ -1081,7 +1081,7 @@ def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
end
# Given a set of columns and an ORDER BY clause, returns the columns for a SELECT DISTINCT.
# PostgreSQL, MySQL, and Oracle override
s
this for custom DISTINCT syntax - they
# PostgreSQL, MySQL, and Oracle override this for custom DISTINCT syntax - they
# require the order columns appear in the SELECT.
#
# columns_for_distinct("posts.id", ["posts.created_at desc"])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录