FFS rails
This commit is contained in:
parent
7e9fab3abe
commit
c4569551d9
1 changed files with 7 additions and 3 deletions
|
@ -1,9 +1,9 @@
|
||||||
class CreateRequests < ActiveRecord::Migration
|
class CreateRequests < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
create_table :requests do |t|
|
create_table :requests do |t|
|
||||||
t.references :debtor, index: true, null: false
|
t.references :debtor, null: false
|
||||||
t.references :creditor, index: true, null: false
|
t.references :creditor, null: false
|
||||||
t.references :issuer, polymorphic: true, index: true, null: false
|
t.references :issuer, polymorphic: true, null: false
|
||||||
t.integer :amount, null: false, default: 0
|
t.integer :amount, null: false, default: 0
|
||||||
t.string :message
|
t.string :message
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@ class CreateRequests < ActiveRecord::Migration
|
||||||
t.timestamps null: false
|
t.timestamps null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index :requests, :debtor_id unless index_exists?(:requests, :debtor)
|
||||||
|
add_index :requests, :creditor_id unless index_exists?(:requests, :creditor)
|
||||||
|
add_index :requests, [:issuer_type, :issuer_id] unless index_exists?(:requests, :issuer)
|
||||||
|
|
||||||
add_foreign_key :requests, :users, column: :creditor_id
|
add_foreign_key :requests, :users, column: :creditor_id
|
||||||
add_foreign_key :requests, :users, column: :debtor_id
|
add_foreign_key :requests, :users, column: :debtor_id
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue