Fix migrations compatibility for default precision value on datetime columns
This commit is contained in:
parent
9b9d9c7bf9
commit
9e3320ad26
@ -48,6 +48,10 @@ def self.compatible_timestamp_type(type, connection)
|
||||
end
|
||||
|
||||
def add_column(table_name, column_name, type, **options)
|
||||
if type == :datetime
|
||||
options[:precision] ||= nil
|
||||
end
|
||||
|
||||
type = PostgreSQLCompat.compatible_timestamp_type(type, connection)
|
||||
super
|
||||
end
|
||||
@ -65,6 +69,11 @@ def new_column_definition(name, type, **options)
|
||||
type = PostgreSQLCompat.compatible_timestamp_type(type, @conn)
|
||||
super
|
||||
end
|
||||
|
||||
def column(name, type, index: nil, **options)
|
||||
options[:precision] ||= nil
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
@ -265,6 +274,8 @@ def add_column(table_name, column_name, type, **options)
|
||||
if type == :primary_key
|
||||
type = :integer
|
||||
options[:primary_key] = true
|
||||
elsif type == :datetime
|
||||
options[:precision] ||= nil
|
||||
end
|
||||
super
|
||||
end
|
||||
@ -295,11 +306,6 @@ def timestamps(**options)
|
||||
options[:null] = true if options[:null].nil?
|
||||
super
|
||||
end
|
||||
|
||||
def column(name, type, index: nil, **options)
|
||||
options[:precision] ||= nil
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def add_reference(table_name, ref_name, **options)
|
||||
@ -329,14 +335,6 @@ def remove_index(table_name, column_name = nil, **options)
|
||||
super
|
||||
end
|
||||
|
||||
def add_column(table_name, column_name, type, **options)
|
||||
if type == :datetime
|
||||
options[:precision] ||= nil
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
private
|
||||
def compatible_table_definition(t)
|
||||
class << t
|
||||
|
Loading…
Reference in New Issue
Block a user