1 class CreateLineItems
< ActiveRecord
::Migration
3 create_table
:line_items do |t
|
4 t
.integer
:product_id, :null => false
5 t
.integer
:order_id, :null => false
6 t
.integer
:quantity, :null => false
7 t
.decimal
:total_price, :null => false, :precision => 8, :scale => 2
12 execute
"alter table line_items add constraint fk_line_item_products
13 foreign key (product_id) references products(id)"
15 execute
"alter table line_items add constraint fk_line_item_orders
16 foreign key (order_id) references orders(id)"
21 drop_table
:line_items