Class: ActiveRecord::ConnectionAdapters::SQLServer::TableDefinition

Inherits:
TableDefinition
  • Object
show all
Includes:
ColumnMethods
Defined in:
lib/active_record/connection_adapters/sqlserver/table_definition.rb

Instance Method Summary collapse

Methods included from ColumnMethods

#binary_basic, #char, #datetime, #datetime2, #datetimeoffset, #json, #money, #nchar, #ntext, #primary_key, #primary_key_nonclustered, #real, #smalldatetime, #smallmoney, #ss_timestamp, #text_basic, #uuid, #varbinary, #varchar, #varchar_max

Instance Method Details

#new_column_definition(name, type, **options) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 102

def new_column_definition(name, type, **options)
  case type
  when :datetime, :timestamp
    # If no precision then default it to 6.
    options[:precision] = 6 unless options.key?(:precision)

    # If there is precision then column must be of type 'datetime2'.
    type = :datetime2 unless options[:precision].nil?
  when :primary_key
    options[:is_identity] = true
  end

  super
end