diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-07-07 10:19:42 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-07-07 10:35:53 +0900 |
commit | 80cbf27f9e435dbf663e7e517c64d7589f91cc49 (patch) | |
tree | 58a28124fc5c4a53be8e378fba647f1e88fa96d3 | |
parent | c9b514cd3e8fe7d74ae91ecd30db839132e7899c (diff) | |
download | rails-80cbf27f9e435dbf663e7e517c64d7589f91cc49.tar.gz rails-80cbf27f9e435dbf663e7e517c64d7589f91cc49.tar.bz2 rails-80cbf27f9e435dbf663e7e517c64d7589f91cc49.zip |
Fix default `CURRENT_TIMESTAMP` in schema dumping for MariaDB 10.2
Since MariaDB 10.2, `CURRENT_TIMESTAMP` is shown as a function
(`current_timestamp()`). Fix matching column default to address that
case.
Fixes #29698.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb index a01fbba201..24f8ff6367 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb @@ -73,8 +73,8 @@ module ActiveRecord def new_column_from_field(table_name, field) type_metadata = fetch_type_metadata(field[:Type], field[:Extra]) - if type_metadata.type == :datetime && field[:Default] == "CURRENT_TIMESTAMP" - default, default_function = nil, field[:Default] + if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\(\))?\z/i.match?(field[:Default]) + default, default_function = nil, "CURRENT_TIMESTAMP" else default, default_function = field[:Default], nil end |