forked from ebhomengo/niki
18 lines
524 B
SQL
18 lines
524 B
SQL
-- +migrate Up
|
|
CREATE TABLE `items` (
|
|
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
|
`cart_id` INT NOT NULL,
|
|
`product_id` INT NOT NULL,
|
|
`quantity` INT NOT NULL DEFAULT 1,
|
|
`price` DECIMAL(10,2) NOT NULL,
|
|
`name` VARCHAR(256),
|
|
`added_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (`cart_id`) REFERENCES `cart`(`id`)
|
|
);
|
|
|
|
CREATE INDEX `idx_items_cart_id` ON `items`(`cart_id`);
|
|
|
|
-- +migrate Down
|
|
DROP INDEX `idx_items_cart_id` ON `items`;
|
|
DROP TABLE `items`;
|