Class: ActiveRecord::ConnectionAdapters::Sqlserver::TableDefinition

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

Instance Method Summary collapse

Instance Method Details

#column(name, type = nil, options = {}) ⇒ Object



16
17
18
19
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 16

def column(name, type = nil, options = {})
  super
  self
end

#primary_key(name, type = :primary_key, options = {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 9

def primary_key(name, type = :primary_key, options = {})
  return super unless type == :uuid
  options[:default] = options.fetch(:default, 'NEWID()')
  options[:primary_key] = true
  column name, type, options
end

#uuid(name, options = {}) ⇒ Object



5
6
7
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 5

def uuid(name, options = {})
  column(name, 'uniqueidentifier', options)
end