diff options
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20230405015505_create_product_carts.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/db/migrate/20230405015505_create_product_carts.rb b/db/migrate/20230405015505_create_product_carts.rb new file mode 100644 index 0000000..4cafb27 --- /dev/null +++ b/db/migrate/20230405015505_create_product_carts.rb @@ -0,0 +1,13 @@ +class CreateProductCarts < ActiveRecord::Migration[7.0] + def change + create_table :product_carts do |t| + t.integer :quantity + t.belongs_to :cart, index: true + t.belongs_to :product, index: true + + t.timestamps + end + + add_index(:product_carts, [:product_id, :cart_id], unique: true) + end +end |