From 97676f01a273a29e43d87d4db87db8376168c547 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Thu, 31 Mar 2016 20:54:37 +0100 Subject: [PATCH] change quantity fields to be decimal(15,3) in database (#429) --- database/2.4_to_3.0.sql | 21 +++++++++++++++++++++ database/database.sql | 17 ++++++++--------- database/migrate_phppos_dist.sql | 17 ++++++++--------- database/tables.sql | 17 ++++++++--------- 4 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 database/2.4_to_3.0.sql diff --git a/database/2.4_to_3.0.sql b/database/2.4_to_3.0.sql new file mode 100644 index 000000000..410d27f85 --- /dev/null +++ b/database/2.4_to_3.0.sql @@ -0,0 +1,21 @@ +-- alter quantity fields + +ALTER TABLE `ospos_items` + MODIFY COLUMN `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', + MODIFY COLUMN `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1' + +ALTER TABLE `ospos_item_kit_items` + MODIFY COLUMN `quantity` decimal(15,3) NOT NULL + +ALTER TABLE `ospos_item_quantities` + MODIFY COLUMN `quantity` decimal(15,3) NOT NULL DEFAULT '0' + +ALTER TABLE `ospos_receivings_items` + MODIFY COLUMN `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', + MODIFY COLUMN `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1' + +ALTER TABLE `ospos_sales_items` + MODIFY COLUMN `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0' + +ALTER TABLE `ospos_sales_suspended_items` + MODIFY COLUMN `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0' \ No newline at end of file diff --git a/database/database.sql b/database/database.sql index 7404d8e9d..17eba62b1 100644 --- a/database/database.sql +++ b/database/database.sql @@ -164,8 +164,8 @@ CREATE TABLE `ospos_items` ( `description` varchar(255) NOT NULL, `cost_price` decimal(15,2) NOT NULL, `unit_price` decimal(15,2) NOT NULL, - `reorder_level` decimal(15,2) NOT NULL DEFAULT '0', - `receiving_quantity` int(11) NOT NULL DEFAULT '1', + `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', `item_id` int(10) NOT NULL AUTO_INCREMENT, `pic_id` int(10) DEFAULT NULL, `allow_alt_description` tinyint(1) NOT NULL, @@ -236,7 +236,7 @@ CREATE TABLE `ospos_item_kits` ( CREATE TABLE `ospos_item_kit_items` ( `item_kit_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, - `quantity` decimal(15,2) NOT NULL, + `quantity` decimal(15,3) NOT NULL, PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`), KEY `ospos_item_kit_items_ibfk_2` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -254,7 +254,7 @@ CREATE TABLE `ospos_item_kit_items` ( CREATE TABLE IF NOT EXISTS `ospos_item_quantities` ( `item_id` int(11) NOT NULL, `location_id` int(11) NOT NULL, - `quantity` int(11) NOT NULL DEFAULT '0', + `quantity` decimal(15,3) NOT NULL DEFAULT '0', PRIMARY KEY (`item_id`,`location_id`), KEY `item_id` (`item_id`), KEY `location_id` (`location_id`) @@ -446,12 +446,12 @@ CREATE TABLE `ospos_receivings_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL, - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', `item_location` int(11) NOT NULL, - `receiving_quantity` int(11) NOT NULL DEFAULT '1', + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', PRIMARY KEY (`receiving_id`,`item_id`,`line`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -498,7 +498,7 @@ CREATE TABLE `ospos_sales_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', @@ -590,7 +590,7 @@ CREATE TABLE `ospos_sales_suspended_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', @@ -702,7 +702,6 @@ CREATE TABLE `ospos_suppliers` ( -- - -- -- Constraints for dumped tables -- diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index 96de768cf..cf1b11108 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -164,8 +164,8 @@ CREATE TABLE `ospos_items` ( `description` varchar(255) NOT NULL, `cost_price` decimal(15,2) NOT NULL, `unit_price` decimal(15,2) NOT NULL, - `reorder_level` decimal(15,2) NOT NULL DEFAULT '0', - `receiving_quantity` int(11) NOT NULL DEFAULT '1', + `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', `item_id` int(10) NOT NULL AUTO_INCREMENT, `pic_id` int(10) DEFAULT NULL, `allow_alt_description` tinyint(1) NOT NULL, @@ -236,7 +236,7 @@ CREATE TABLE `ospos_item_kits` ( CREATE TABLE `ospos_item_kit_items` ( `item_kit_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, - `quantity` decimal(15,2) NOT NULL, + `quantity` decimal(15,3) NOT NULL, PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`), KEY `ospos_item_kit_items_ibfk_2` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -254,7 +254,7 @@ CREATE TABLE `ospos_item_kit_items` ( CREATE TABLE IF NOT EXISTS `ospos_item_quantities` ( `item_id` int(11) NOT NULL, `location_id` int(11) NOT NULL, - `quantity` int(11) NOT NULL DEFAULT '0', + `quantity` decimal(15,3) NOT NULL DEFAULT '0', PRIMARY KEY (`item_id`,`location_id`), KEY `item_id` (`item_id`), KEY `location_id` (`location_id`) @@ -446,12 +446,12 @@ CREATE TABLE `ospos_receivings_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL, - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', `item_location` int(11) NOT NULL, - `receiving_quantity` int(11) NOT NULL DEFAULT '1', + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', PRIMARY KEY (`receiving_id`,`item_id`,`line`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -498,7 +498,7 @@ CREATE TABLE `ospos_sales_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', @@ -590,7 +590,7 @@ CREATE TABLE `ospos_sales_suspended_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', @@ -702,7 +702,6 @@ CREATE TABLE `ospos_suppliers` ( -- - -- -- This migration script should be run after creating tables with the regular database script and before applying the constraints. -- diff --git a/database/tables.sql b/database/tables.sql index 5a49247fc..e441a8af5 100644 --- a/database/tables.sql +++ b/database/tables.sql @@ -164,8 +164,8 @@ CREATE TABLE `ospos_items` ( `description` varchar(255) NOT NULL, `cost_price` decimal(15,2) NOT NULL, `unit_price` decimal(15,2) NOT NULL, - `reorder_level` decimal(15,2) NOT NULL DEFAULT '0', - `receiving_quantity` int(11) NOT NULL DEFAULT '1', + `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', `item_id` int(10) NOT NULL AUTO_INCREMENT, `pic_id` int(10) DEFAULT NULL, `allow_alt_description` tinyint(1) NOT NULL, @@ -236,7 +236,7 @@ CREATE TABLE `ospos_item_kits` ( CREATE TABLE `ospos_item_kit_items` ( `item_kit_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, - `quantity` decimal(15,2) NOT NULL, + `quantity` decimal(15,3) NOT NULL, PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`), KEY `ospos_item_kit_items_ibfk_2` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -254,7 +254,7 @@ CREATE TABLE `ospos_item_kit_items` ( CREATE TABLE IF NOT EXISTS `ospos_item_quantities` ( `item_id` int(11) NOT NULL, `location_id` int(11) NOT NULL, - `quantity` int(11) NOT NULL DEFAULT '0', + `quantity` decimal(15,3) NOT NULL DEFAULT '0', PRIMARY KEY (`item_id`,`location_id`), KEY `item_id` (`item_id`), KEY `location_id` (`location_id`) @@ -446,12 +446,12 @@ CREATE TABLE `ospos_receivings_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL, - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', `item_location` int(11) NOT NULL, - `receiving_quantity` int(11) NOT NULL DEFAULT '1', + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', PRIMARY KEY (`receiving_id`,`item_id`,`line`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -498,7 +498,7 @@ CREATE TABLE `ospos_sales_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', @@ -590,7 +590,7 @@ CREATE TABLE `ospos_sales_suspended_items` ( `description` varchar(30) DEFAULT NULL, `serialnumber` varchar(30) DEFAULT NULL, `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,2) NOT NULL DEFAULT '0.00', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', `item_cost_price` decimal(15,2) NOT NULL, `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', @@ -701,4 +701,3 @@ CREATE TABLE `ospos_suppliers` ( -- Dumping data for table `ospos_suppliers` -- -