From a61bc10dde5b6b76d4d23650939b47a8402ba376 Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Sun, 17 Aug 2014 00:49:48 +0200 Subject: [PATCH] Location column is kept in database Added a data migration script for stock_locations and item_quantities tables --- database/2.2.2_to_2.3.sql | 2 +- database/2.3_migrate_locations.sql | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 database/2.3_migrate_locations.sql diff --git a/database/2.2.2_to_2.3.sql b/database/2.2.2_to_2.3.sql index cb287b0e9..458bf9063 100644 --- a/database/2.2.2_to_2.3.sql +++ b/database/2.2.2_to_2.3.sql @@ -19,7 +19,7 @@ ALTER TABLE ospos_inventory ADD KEY `trans_location` (`trans_location`), ADD CONSTRAINT `ospos_inventory_ibfk_3` FOREIGN KEY (`trans_location`) REFERENCES `ospos_stock_locations` (`location_id`); -ALTER TABLE ospos_items DROP COLUMN location; +-- ALTER TABLE ospos_items DROP COLUMN location; INSERT INTO `ospos_stock_locations` ( `deleted`, `location_name` ) VALUES ('0', 'stock'); diff --git a/database/2.3_migrate_locations.sql b/database/2.3_migrate_locations.sql new file mode 100644 index 000000000..cb1ec3087 --- /dev/null +++ b/database/2.3_migrate_locations.sql @@ -0,0 +1,2 @@ +INSERT INTO ospos_stock_locations (location_name) (SELECT location FROM ospos_items WHERE NOT EXISTS (select location from ospos_stock_locations where location_name = location)); +INSERT INTO ospos_item_quantities (item_id, location_id, quantity) (SELECT item_id, location_id, quantity FROM ospos_items, ospos_stock_locations where ospos_items.location = ospos_stock_locations.location_name);