forked from amir_tavakolian/niki
24 lines
1.3 KiB
SQL
24 lines
1.3 KiB
SQL
-- +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 `orders` (
|
|
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
|
`user_id` INT NOT NULL,
|
|
`address` TEXT,
|
|
`shipping_id` INT NOT NULL,
|
|
`payment_method` ENUM('online', 'wallet', 'cart') DEFAULT 'online',
|
|
`payment_status` ENUM('unpaid', 'paid', 'cancelled') DEFAULT 'unpaid',
|
|
`process_status` ENUM('waiting-to-pay', 'processing', 'accepted', 'preparing', 'prepared', 'given-to-post', 'delivered', 'cancelled') DEFAULT 'waiting-to-pay',
|
|
`total_amount` INT NOT NULL,
|
|
`total_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 (`user_id`) REFERENCES `users`(`id`)
|
|
-- FOREIGN KEY (`shipping_id`) REFERENCES `shippings`(`id`)
|
|
|
|
);
|
|
|
|
-- +migrate Down
|
|
DROP TABLE `orders`;
|