From aadf6151229001c5659f91b353e83b4cad9afbf5 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 8 Sep 2015 15:37:02 +0200 Subject: [PATCH] fix transaction foreign keys --- db/migrate/20150908091546_create_transactions.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/db/migrate/20150908091546_create_transactions.rb b/db/migrate/20150908091546_create_transactions.rb index de40fa3..6fc8ad4 100644 --- a/db/migrate/20150908091546_create_transactions.rb +++ b/db/migrate/20150908091546_create_transactions.rb @@ -1,13 +1,16 @@ class CreateTransactions < ActiveRecord::Migration def change create_table :transactions do |t| - t.references :debtor, index: true, foreign_key: true, null: false - t.references :creditor, index: true, foreign_key: true, null: false + t.references :debtor, index: true, null: false + t.references :creditor, index: true, null: false t.integer :amount, null: false, default: 0 t.string :origin, null: false t.string :message t.timestamps null: false end + + add_foreign_key :transactions, :users, :creditor_id + add_foreign_key :transactions, :users, :debtor_id end end