This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE `store` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; | |
USE store; | |
CREATE TABLE `users` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`first_name` varchar(127) NOT NULL, | |
`last_name` varchar(128) NOT NULL, | |
`email` varchar(255) NOT NULL, | |
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4; | |
CREATE TABLE `products` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`sku` varchar(255) NOT NULL, | |
`name` varchar(255) NOT NULL, | |
`description` text, | |
`price` decimal(10,2) NOT NULL, | |
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4; | |
CREATE TABLE `orders` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`user_id` int(11) NOT NULL, | |
`total` decimal(10,2) NOT NULL DEFAULT '0.00', | |
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4; | |
CREATE TABLE `orders_items` ( | |
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | |
`order_id` int(10) unsigned NOT NULL, | |
`product_id` int(10) unsigned NOT NULL, | |
`product_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00', | |
`quantity` int(10) unsigned NOT NULL DEFAULT 1, | |
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
`updated_at` varchar(45) NOT NULL DEFAULT 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment