36782-vm/db/migrations/005_create_order_items_table.sql
2025-12-12 14:13:03 +00:00

14 lines
431 B
SQL

-- Create order_items table
CREATE TABLE IF NOT EXISTS order_items (
id INT AUTO_INCREMENT PRIMARY KEY,
order_id INT NOT NULL,
product_id INT NOT NULL,
quantity INT NOT NULL,
unit_price DECIMAL(10, 2) NOT NULL,
line_total DECIMAL(10, 2) NOT NULL,
supplier_id INT,
delivery_source VARCHAR(50),
FOREIGN KEY (order_id) REFERENCES orders(id),
FOREIGN KEY (product_id) REFERENCES products(id)
);