From 9864b126a827af7c5f9b3c946fa9f6d68b1ca203 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Thu, 24 Aug 2017 14:02:20 +0400 Subject: [PATCH 1/3] SQL Fails if key already exists Using the IGNORE keyword bypasses the insert of that key if it already exists and moves onto the next one. --- database/3.0.2_to_3.1.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/3.0.2_to_3.1.0.sql b/database/3.0.2_to_3.1.0.sql index 1c1f7ef40..7dd16308c 100644 --- a/database/3.0.2_to_3.1.0.sql +++ b/database/3.0.2_to_3.1.0.sql @@ -187,7 +187,7 @@ ALTER TABLE `ospos_sales_items_taxes` ALTER TABLE `ospos_customers` ADD COLUMN `sales_tax_code` varchar(32) NOT NULL DEFAULT '1'; -INSERT INTO `ospos_app_config` (`key`, `value`) VALUES +INSERT IGNORE INTO `ospos_app_config` (`key`, `value`) VALUES ('customer_sales_tax_support', '0'), ('default_origin_tax_code', ''), ('default_tax_category', 'Standard'), From d4ddb4c8ee5a217a9bf1a936afad6ddd0860a837 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Thu, 24 Aug 2017 14:08:23 +0400 Subject: [PATCH 2/3] IGNORE statement prevents mysql error if already exists --- database/3.0.2_to_3.1.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/3.0.2_to_3.1.0.sql b/database/3.0.2_to_3.1.0.sql index 7dd16308c..84c87e69c 100644 --- a/database/3.0.2_to_3.1.0.sql +++ b/database/3.0.2_to_3.1.0.sql @@ -196,10 +196,10 @@ INSERT IGNORE INTO `ospos_app_config` (`key`, `value`) VALUES ('default_tax_2_name', ''), ('default_tax_2_rate', ''); -INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_id`) VALUES +INSERT IGNORE INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_id`) VALUES ('module_taxes', 'module_taxes_desc', 105, 'taxes'); -INSERT INTO `ospos_permissions` (`permission_id`, `module_id`) VALUES +INSERT IGNORE INTO `ospos_permissions` (`permission_id`, `module_id`) VALUES ('taxes', 'taxes'); -- add support for cash rounding into config From 477dcb78dbeea6e2849a6801ea80c8e34205b691 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Thu, 24 Aug 2017 14:28:23 +0400 Subject: [PATCH 3/3] comment should be default null --- database/3.0.2_to_3.1.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/3.0.2_to_3.1.0.sql b/database/3.0.2_to_3.1.0.sql index 84c87e69c..0fc27059e 100644 --- a/database/3.0.2_to_3.1.0.sql +++ b/database/3.0.2_to_3.1.0.sql @@ -358,7 +358,7 @@ ALTER TABLE ospos_items MODIFY unit_price decimal(15,2) NOT NULL; ALTER TABLE ospos_receivings MODIFY comment text NOT NULL; ALTER TABLE ospos_receivings_items MODIFY discount_percent decimal(15,2) NOT NULL DEFAULT '0.00'; ALTER TABLE ospos_receivings_items MODIFY item_unit_price decimal(15,2) NOT NULL; -ALTER TABLE ospos_sales MODIFY comment text NOT NULL; +ALTER TABLE ospos_sales MODIFY comment text DEFAULT NULL; ALTER TABLE ospos_sales_items MODIFY discount_percent decimal(15,2) NOT NULL DEFAULT '0.00'; ALTER TABLE ospos_sales_items MODIFY item_unit_price decimal(15,2) NOT NULL;