From: Roland Haeder Date: Thu, 17 Sep 2015 10:46:54 +0000 (+0200) Subject: fixed SQL file + updated jar X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=be964054831c41f2995b570f533e3f9820ee31da;p=pizzaservice-ejb.git fixed SQL file + updated jar Signed-off-by:Roland Häder --- diff --git a/PizzaService-ejb/lib/jcore.jar b/PizzaService-ejb/lib/jcore.jar index 4426c96..107bb12 100644 Binary files a/PizzaService-ejb/lib/jcore.jar and b/PizzaService-ejb/lib/jcore.jar differ diff --git a/PizzaService-ejb/lib/jshop-core.jar b/PizzaService-ejb/lib/jshop-core.jar index a083ae7..f6c7a42 100644 Binary files a/PizzaService-ejb/lib/jshop-core.jar and b/PizzaService-ejb/lib/jshop-core.jar differ diff --git a/install/install.sql b/install/install.sql index a59bab4..61e8e90 100644 --- a/install/install.sql +++ b/install/install.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS `contacts` ( `fax_number` varchar(100) DEFAULT NULL COMMENT 'Fax number', `email_address` varchar(100) DEFAULT NULL COMMENT 'Email addres', `birthday` date DEFAULT NULL COMMENT 'Birth day', - `comment` tinytext NOT NULL COMMENT 'Comment', + `comment` tinytext NULL DEFAULT NULL COMMENT 'Comment', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Entry created', `updated` timestamp NULL DEFAULT NULL COMMENT 'Entry updated', PRIMARY KEY (`id`) @@ -33,11 +33,11 @@ CREATE TABLE IF NOT EXISTS `customer` ( `id` bigint(20) unsigned NOT NULL COMMENT 'Primay key', `customer_contact_id` bigint(20) unsigned NOT NULL COMMENT 'Table reference on "contact"', `customer_number` varchar(20) COLLATE 'utf8mb4_general_ci' NOT NULL COMMENT 'Customer number', - `customer_password_hash` varchar(255) COLLATE 'utf8mb4_general_ci' NOT NULL COMMENT 'Password hash', + `customer_password_hash` varchar(255) COLLATE 'utf8mb4_general_ci' NULL DEFAULT NULL COMMENT 'Password hash', `customer_confirm_key` varchar(50) COLLATE 'utf8mb4_general_ci' NULL DEFAULT NULL COMMENT 'Email confirmation key', `customer_status` enum('UNCONFIRMED','CONFIRMED','LOCKED') COLLATE 'utf8mb4_general_ci' NOT NULL DEFAULT 'UNCONFIRMED' COMMENT 'Account status', `customer_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Account creation', - `customer_locked` datetime NULL COMMENT 'Last locked timestamp', + `customer_locked` datetime NULL DEFAULT NULL COMMENT 'Last locked timestamp', PRIMARY KEY (`id`), UNIQUE (`customer_confirm_key`), UNIQUE (`customer_number`), @@ -54,6 +54,18 @@ CREATE TABLE IF NOT EXISTS `products` ( INDEX `category` (`category`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb4 COMMENT='Products' ; +CREATE TABLE IF NOT EXISTS `orders` ( + `id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', + `order_status` enum('UNCONFIRMED','CONFIRMED','DELIVERED','CANCELED') NOT NULL DEFAULT 'UNCONFIRMED' COMMENT 'Order status', + `customer_id` bigint(20) unsigned DEFAULT NULL COMMENT 'Table reference customer', + `product_id` bigint(20) unsigned NOT NULL COMMENT 'Table reference products', + `amount` bigint(20) unsigned NOT NULL COMMENT 'Ordered amount', + `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Record inserted', + PRIMARY KEY (`id`), + INDEX `product_id` (`product_id`), + INDEX `customer_product` (`customer_id`,`product_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Customer orders'; + ALTER TABLE `category` MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key'; @@ -66,6 +78,9 @@ MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key'; ALTER TABLE `products` MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key'; +ALTER TABLE `orders` +MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key'; + ALTER TABLE `category` ADD FOREIGN KEY (`parent`) REFERENCES `category` (`id`) ON DELETE SET NULL; @@ -74,3 +89,7 @@ ADD FOREIGN KEY (`customer_contact_id`) REFERENCES `contacts` (`id`) ON DELETE C ALTER TABLE `products` ADD FOREIGN KEY (`category`) REFERENCES `category` (`id`) ON DELETE SET NULL; + +ALTER TABLE `orders` +ADD CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE SET NULL, +ADD CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;