Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d505ba03
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,发现更多精彩内容 >>
提交
d505ba03
编写于
2月 01, 2016
作者:
R
Rafael França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23168 from kamipo/avoid_extra_show_variables_in_migration
Avoid extra `show variables` in migration
上级
2f8ba24e
57604cf2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
21 deletion
+15
-21
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
..._record/connection_adapters/abstract/schema_statements.rb
+5
-1
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+5
-7
activerecord/lib/active_record/internal_metadata.rb
activerecord/lib/active_record/internal_metadata.rb
+3
-5
activerecord/lib/active_record/schema_migration.rb
activerecord/lib/active_record/schema_migration.rb
+2
-3
activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb
...cord/test/cases/adapters/mysql2/schema_migrations_test.rb
+0
-5
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
浏览文件 @
d505ba03
...
...
@@ -115,7 +115,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
checks
=
[]
checks
<<
lambda
{
|
c
|
c
.
name
==
column_name
}
checks
<<
lambda
{
|
c
|
c
.
type
==
type
}
if
type
[
:limit
,
:precision
,
:scale
,
:default
,
:null
]
.
each
do
|
attr
|
(
migration_keys
-
[
:name
])
.
each
do
|
attr
|
checks
<<
lambda
{
|
c
|
c
.
send
(
attr
)
==
options
[
attr
]
}
if
options
.
key?
(
attr
)
end
...
...
@@ -981,6 +981,10 @@ def initialize_internal_metadata_table
ActiveRecord
::
InternalMetadata
.
create_table
end
def
internal_string_options_for_primary_key
# :nodoc:
{
primary_key:
true
}
end
def
assume_migrated_upto_version
(
version
,
migrations_paths
)
migrations_paths
=
Array
(
migrations_paths
)
version
=
version
.
to_i
...
...
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
d505ba03
...
...
@@ -67,14 +67,12 @@ def initialize(connection, logger, connection_options, config)
end
end
MAX_INDEX_LENGTH_FOR_CHARSETS_OF_4BYTES_MAXLEN
=
191
CHARSETS_OF_4BYTES_MAXLEN
=
[
'utf8mb4'
,
'utf16'
,
'utf16le'
,
'utf32'
]
def
initialize_schema_migrations_table
if
CHARSETS_OF_4BYTES_MAXLEN
.
include?
(
charset
)
ActiveRecord
::
SchemaMigration
.
create_table
(
MAX_INDEX_LENGTH_FOR_CHARSETS_OF_4BYTES_MAXLEN
)
else
ActiveRecord
::
SchemaMigration
.
create_table
end
def
internal_string_options_for_primary_key
# :nodoc:
super
.
tap
{
|
options
|
options
[
:collation
]
=
collation
.
sub
(
/\A[^_]+/
,
'utf8'
)
if
CHARSETS_OF_4BYTES_MAXLEN
.
include?
(
charset
)
}
end
def
version
...
...
activerecord/lib/active_record/internal_metadata.rb
浏览文件 @
d505ba03
...
...
@@ -5,10 +5,6 @@ module ActiveRecord
# This class is used to create a table that keeps track of values and keys such
# as which environment migrations were run in.
class
InternalMetadata
<
ActiveRecord
::
Base
# :nodoc:
# Keys in mysql are limited to 191 characters, due to this no adapter can
# use a longer key
KEY_LIMIT
=
191
class
<<
self
def
primary_key
"key"
...
...
@@ -33,8 +29,10 @@ def table_exists?
# Creates an internal metadata table with columns +key+ and +value+
def
create_table
unless
table_exists?
key_options
=
connection
.
internal_string_options_for_primary_key
connection
.
create_table
(
table_name
,
id:
false
)
do
|
t
|
t
.
string
:key
,
primary_key:
true
,
limit:
KEY_LIMIT
t
.
string
:key
,
key_options
t
.
string
:value
t
.
timestamps
end
...
...
activerecord/lib/active_record/schema_migration.rb
浏览文件 @
d505ba03
...
...
@@ -20,10 +20,9 @@ def table_exists?
ActiveSupport
::
Deprecation
.
silence
{
connection
.
table_exists?
(
table_name
)
}
end
def
create_table
(
limit
=
nil
)
def
create_table
unless
table_exists?
version_options
=
{
primary_key:
true
}
version_options
[
:limit
]
=
limit
if
limit
version_options
=
connection
.
internal_string_options_for_primary_key
connection
.
create_table
(
table_name
,
id:
false
)
do
|
t
|
t
.
string
:version
,
version_options
...
...
activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb
浏览文件 @
d505ba03
...
...
@@ -33,11 +33,6 @@ def test_initializes_internal_metadata_for_encoding_utf8mb4
end
end
def
test_key_limit_max_matches_max
assert_equal
ActiveRecord
::
InternalMetadata
::
KEY_LIMIT
,
ActiveRecord
::
ConnectionAdapters
::
Mysql2Adapter
::
MAX_INDEX_LENGTH_FOR_CHARSETS_OF_4BYTES_MAXLEN
end
private
def
with_encoding_utf8mb4
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录