fix transaction foreign keys
This commit is contained in:
parent
9cbd5a141c
commit
aadf615122
1 changed files with 5 additions and 2 deletions
|
@ -1,13 +1,16 @@
|
||||||
class CreateTransactions < ActiveRecord::Migration
|
class CreateTransactions < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
create_table :transactions do |t|
|
create_table :transactions do |t|
|
||||||
t.references :debtor, index: true, foreign_key: true, null: false
|
t.references :debtor, index: true, null: false
|
||||||
t.references :creditor, index: true, foreign_key: true, null: false
|
t.references :creditor, index: true, null: false
|
||||||
t.integer :amount, null: false, default: 0
|
t.integer :amount, null: false, default: 0
|
||||||
t.string :origin, null: false
|
t.string :origin, null: false
|
||||||
t.string :message
|
t.string :message
|
||||||
|
|
||||||
t.timestamps null: false
|
t.timestamps null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_foreign_key :transactions, :users, :creditor_id
|
||||||
|
add_foreign_key :transactions, :users, :debtor_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue