Class: ActiveRecord::ConnectionAdapters::TableDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord-postgres-json/activerecord.rb

Instance Method Summary collapse

Instance Method Details

#json(*args) ⇒ Object

Adds json type for migrations. So you can add columns to a table like:

create_table :people do |t|
  ...
  t.json :info
  ...
end


62
63
64
65
66
# File 'lib/activerecord-postgres-json/activerecord.rb', line 62

def json(*args)
  options = args.extract_options!
  column_names = args
  column_names.each { |name| column(name, 'json', options) }
end

#jsonb(*args) ⇒ Object



68
69
70
71
72
# File 'lib/activerecord-postgres-json/activerecord.rb', line 68

def jsonb(*args)
  options = args.extract_options!
  column_names = args
  column_names.each { |name| column(name, 'jsonb', options) }
end