Method: Netfira::WebConnect::Migration#create_relation_table

Defined in:
lib/netfira/web_connect/migration.rb

#create_relation_table(first, second) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/netfira/web_connect/migration.rb', line 62

def create_relation_table(first, second)
  first, second = [first, second].sort
  create_table :"#{first}_to_#{second}" do |t|
    t.references first.to_s.singularize, second.to_s.singularize, index: true
    t.timestamps
    t.datetime :deleted_at
    t.index :deleted_at
  end
end