Commit 0a863c8b authored by Michael Kozono's avatar Michael Kozono

Add `datetime_with_timezone` to table definition

So the method can be used in a `create_table` block. There is a new Rubocop style cop that requires the usage of `datetime_with_timezone`.
parent 45b1de84
......@@ -3,15 +3,15 @@
require 'active_record/connection_adapters/abstract/schema_definitions'
# Appends columns `created_at` and `updated_at` to a table.
#
# It is used in table creation like:
# create_table 'users' do |t|
# t.timestamps_with_timezone
# end
module ActiveRecord
module ConnectionAdapters
class TableDefinition
# Appends columns `created_at` and `updated_at` to a table.
#
# It is used in table creation like:
# create_table 'users' do |t|
# t.timestamps_with_timezone
# end
def timestamps_with_timezone(**options)
options[:null] = false if options[:null].nil?
......@@ -19,6 +19,16 @@ module ActiveRecord
column(column_name, :datetime_with_timezone, options)
end
end
# Adds specified column with appropriate timestamp type
#
# It is used in table creation like:
# create_table 'users' do |t|
# t.datetime_with_timezone :did_something_at
# end
def datetime_with_timezone(column_name, **options)
column(column_name, :datetime_with_timezone, options)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment