diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-09-23 09:09:50 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-09-23 09:09:50 -0600 |
commit | f696494aedf453d8fd51a13005dfbd34477ccc45 (patch) | |
tree | 75fef7b5a8e1a23a9e82c00deeea6ba8f0d0cdf2 /activerecord/test/schema | |
parent | 66337b62ad5fe8004394608584baff137f4cc93e (diff) | |
download | rails-f696494aedf453d8fd51a13005dfbd34477ccc45.tar.gz rails-f696494aedf453d8fd51a13005dfbd34477ccc45.tar.bz2 rails-f696494aedf453d8fd51a13005dfbd34477ccc45.zip |
Don't attempt to specify datetime precision unless supported
Specifically, versions of MySQL prior to 5.6 do not support this, which
is what's used on Travis by default. The method `mysql_56?` appeared to
only ever be used to conditionally apply subsecond precision, so I've
generalized it and used it more liberally.
This should fix the test failures caused by #20317
Diffstat (limited to 'activerecord/test/schema')
-rw-r--r-- | activerecord/test/schema/schema.rb | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index ae183ade81..c39b8d28ca 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -251,10 +251,17 @@ ActiveRecord::Schema.define do create_table :developers, force: true do |t| t.string :name t.integer :salary, default: 70000 - t.datetime :created_at, precision: 6 - t.datetime :updated_at, precision: 6 - t.datetime :created_on, precision: 6 - t.datetime :updated_on, precision: 6 + if subsecond_precision_supported? + t.datetime :created_at, precision: 6 + t.datetime :updated_at, precision: 6 + t.datetime :created_on, precision: 6 + t.datetime :updated_on, precision: 6 + else + t.datetime :created_at + t.datetime :updated_at + t.datetime :created_on + t.datetime :updated_on + end end create_table :developers_projects, force: true, id: false do |t| @@ -353,7 +360,11 @@ ActiveRecord::Schema.define do create_table :invoices, force: true do |t| t.integer :balance - t.datetime :updated_at, precision: 6 + if subsecond_precision_supported? + t.datetime :updated_at, precision: 6 + else + t.datetime :updated_at + end end create_table :iris, force: true do |t| @@ -503,7 +514,11 @@ ActiveRecord::Schema.define do create_table :owners, primary_key: :owner_id, force: true do |t| t.string :name - t.column :updated_at, :datetime, precision: 6 + if subsecond_precision_supported? + t.column :updated_at, :datetime, precision: 6 + else + t.column :updated_at, :datetime + end t.column :happy_at, :datetime t.string :essay_id end @@ -755,7 +770,7 @@ ActiveRecord::Schema.define do t.string :title, limit: 250 t.string :author_name t.string :author_email_address - if mysql_56? + if subsecond_precision_supported? t.datetime :written_on, precision: 6 else t.datetime :written_on @@ -778,7 +793,11 @@ ActiveRecord::Schema.define do t.string :parent_title t.string :type t.string :group - t.timestamps null: true, precision: 6 + if subsecond_precision_supported? + t.timestamps null: true, precision: 6 + else + t.timestamps null: true + end end create_table :toys, primary_key: :toy_id, force: true do |t| |