summaryrefslogtreecommitdiff
path: root/db/migrate/20230405015505_create_product_carts.rb
blob: 4cafb275d0bb912d315e879cffbdb107d3d229d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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