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