-- +migrate Up
-- please read this article to understand why we use VARCHAR(191)
-- https://www.grouparoo.com/blog/varchar-191#why-varchar-and-not-text
CREATE TABLE `order_items` (
                               `id`                  INT PRIMARY KEY AUTO_INCREMENT,
                               `order_id`            INT NOT NULL,
                               `product_id`          INT NOT NULL,
                               `quantity`            INT DEFAULT 1,
                               `price`               INT NOT NULL,
                               `price_with_discount` INT NULL,
                               `created_at`          TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
                               `updated_at`          TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

                                FOREIGN KEY (`order_id`) REFERENCES `orders`(`id`)

);

-- +migrate Down
DROP TABLE `order_items`;
