aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-01-18 09:57:10 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-01-26 22:49:14 +0900
commit57015cdfa2083351f64a82f7566965172a41efcb (patch)
treed6f859c2cfbc7b8bc7ba85c3de0efb5bba0a70e4 /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
parent5fe6d3747efd37d7d8c6c9d6557d7b623e0398e8 (diff)
downloadrails-57015cdfa2083351f64a82f7566965172a41efcb.tar.gz
rails-57015cdfa2083351f64a82f7566965172a41efcb.tar.bz2
rails-57015cdfa2083351f64a82f7566965172a41efcb.zip
Make `t.timestamps` with precision by default
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index 9c44cf46aa..946436f7f9 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -637,7 +637,7 @@ module ActiveRecord
end
def create_table_definition(*args)
- PostgreSQL::TableDefinition.new(*args)
+ PostgreSQL::TableDefinition.new(self, *args)
end
def create_alter_table(name)
@@ -718,6 +718,10 @@ module ActiveRecord
def add_timestamps_for_alter(table_name, options = {})
options[:null] = false if options[:null].nil?
+ if !options.key?(:precision) && supports_datetime_with_precision?
+ options[:precision] = 6
+ end
+
[add_column_for_alter(table_name, :created_at, :datetime, options), add_column_for_alter(table_name, :updated_at, :datetime, options)]
end