orders table
iamvu
mysql
10 months ago
652 B
9
Indexable
CREATE TABLE `orders` (
`id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`user_id` BIGINT UNSIGNED NOT NULL,
`cart_id` BIGINT UNSIGNED NOT NULL,
`total_price` DECIMAL(20,2) NOT NULL,
`payment_status` ENUM('pending', 'paid', 'failed') DEFAULT 'pending',
`payment_method` ENUM('cod', 'credit_card', 'paypal') NOT NULL,
`shipping_address` TEXT NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
FOREIGN KEY (`cart_id`) REFERENCES `carts`(`id`) ON DELETE CASCADE
);
Editor is loading...
Leave a Comment