about summary refs log tree commit diff
path: root/db/migrate/20190805203816_create_linked_users.rb
blob: 36744fed68b4a851cd4559f89e3e692465144eea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class CreateLinkedUsers < ActiveRecord::Migration[5.2]
  def change
    create_table :linked_users do |t|
      t.references :user, foreign_key: { on_delete: :cascade }
      t.references :target_user, foreign_key: { to_table: 'users', on_delete: :cascade }

      t.timestamps
    end

    add_index :linked_users , [:user_id, :target_user_id], :unique => true
  end
end