Class: ActiveRecord::ConnectionAdapters::BigqueryAdapter::TableDefinition

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

Instance Method Summary collapse

Instance Method Details

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



390
391
392
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 390

def primary_key(name, type = :primary_key, options = {})
  return column name, :string, options
end

#record(*args) ⇒ Object



394
395
396
397
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 394

def record(*args)
  options = args.extract_options!
  column(:created_at, :record, options)
end

#references(*args) ⇒ Object



405
406
407
408
409
410
411
412
413
414
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 405

def references(*args)
  options = args.extract_options!
  polymorphic = options.delete(:polymorphic)
  index_options = options.delete(:index)
  args.each do |col|
    column("#{col}_id", :string, options)
    column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) if polymorphic
    index(polymorphic ? %w(id type).map { |t| "#{col}_#{t}" } : "#{col}_id", index_options.is_a?(Hash) ? index_options : {}) if index_options
  end
end

#timestamps(*args) ⇒ Object



399
400
401
402
403
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 399

def timestamps(*args)
  options = args.extract_options!
  column(:created_at, :timestamp, options)
  column(:updated_at, :timestamp, options)
end