From 89f126ab047eef563943efcfc8c59487354a0e47 Mon Sep 17 00:00:00 2001 From: jekkos Date: Sun, 31 Jan 2016 15:24:42 +0100 Subject: [PATCH 1/7] Use curl to wait for apache start (#305) --- .travis.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c85fe0f7..ff00e26be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ before_install: - docker run -d jekkos/opensourcepos script: - - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "wget --retry-connrefused --tries=5 -q --waitretry=3 --spider http://localhost/index.php && cd /app && grunt mochaWebdriver:test" + - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "while ! curl http://localhost/index.php; do sleep 1; done; cd app && grunt mochaWebdriver:test" diff --git a/Dockerfile b/Dockerfile index 6e9517c6e..7ab050f49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:trusty MAINTAINER jekkos RUN apt-get update RUN apt-get -y upgrade -RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm wget +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm curl RUN easy_install supervisor ADD ./docker/foreground.sh /etc/apache2/foreground.sh ADD ./docker/supervisord.conf /etc/supervisord.conf From 48a16d65e17777e0c1c38be0a9c851b37cf3d933 Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 3 Feb 2016 10:49:20 +0100 Subject: [PATCH 2/7] Fix base url for testcases (#305) Fix legacy ubuntu repository urls (#284) --- Dockerfile | 3 ++- test/ospos.js | 60 +++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ab050f49..b4f8de14f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -FROM ubuntu:trusty +FROM ubuntu:utopic MAINTAINER jekkos +RUN sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list RUN apt-get update RUN apt-get -y upgrade RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm curl diff --git a/test/ospos.js b/test/ospos.js index a361b6386..b26f5be6f 100644 --- a/test/ospos.js +++ b/test/ospos.js @@ -2,7 +2,7 @@ var assert = require('assert'); var ospos = function() { - var server = "http://localhost/index.php"; + var server = "http://localhost"; return { @@ -10,38 +10,38 @@ var ospos = function() { return server + suffix; } , - login : function(browser, done) { - return browser.get(this.url("/index.php")) - .elementByName('username').type("admin").getValue() - .then(function (value) { - assert.equal(value, "admin"); - }) - .elementByName('password').type("pointofsale").getValue() - .then(function (value) { - assert.ok(value, "pointofsale"); - }) - .elementByName('loginButton').click() - .elementById('home_module_list').then(function (value) { - assert.ok(value, "Login failed!!") - }) - .then(done, done); + login : function(browser, done) { + return browser.get(this.url("/index.php")) + .elementByName('username').type("admin").getValue() + .then(function (value) { + assert.equal(value, "admin"); + }) + .elementByName('password').type("pointofsale").getValue() + .then(function (value) { + assert.ok(value, "pointofsale"); + }) + .elementByName('loginButton').click() + .elementById('home_module_list').then(function (value) { + assert.ok(value, "Login failed!!") + }) + .then(done, done); - }, + }, - create_item : function(browser, item) - { - return browser.get(this.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() - .waitForElementByName("name", 10000).type(item.name).elementById("category").type(item.category) - .elementById('cost_price', 2000).clear().type(item.cost_price).elementById("unit_price", 2000).type(item.unit_price) - .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") - .elementById('receiving_quantity', 2000).type(item.receiving_quantity || 1) - .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() - .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { - assert.equal(value, "anItem", "item " + item.name + " could not be created!!"); - }); - } + create_item : function(browser, item) + { + return browser.get(this.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() + .waitForElementByName("name", 10000).type(item.name).elementById("category").type(item.category) + .elementById('cost_price', 2000).clear().type(item.cost_price).elementById("unit_price", 2000).type(item.unit_price) + .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") + .elementById('receiving_quantity', 2000).type(item.receiving_quantity || 1) + .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() + .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { + assert.equal(value, "anItem", "item " + item.name + " could not be created!!"); + }); + } } }; -module.exports = ospos(); \ No newline at end of file +module.exports = ospos(); From acd9beae7300184aa74bd51aff5aa4960727a3c6 Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 3 Feb 2016 17:29:01 +0100 Subject: [PATCH 3/7] Set npm package version number --- .travis.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff00e26be..94d0f227a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ before_install: - docker run -d jekkos/opensourcepos script: - - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "while ! curl http://localhost/index.php; do sleep 1; done; cd app && grunt mochaWebdriver:test" + - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "while ! curl http://localhost/index.php | grep username; do sleep 1; done; cd app && grunt mochaWebdriver:test" diff --git a/package.json b/package.json index 31472a0f4..90ce7d94c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opensourcepos", - "version": "2.3.3", + "version": "2.3.4", "description": "Open Source Point of Sale is a web based point of sale system written in the PHP language. It uses MySQL as the data storage back-end and has a simple user interface.", "main": "index.php", "scripts": { From 9d056b2765d2db3b41b4a666f42bb50b4d230c59 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sun, 31 Jan 2016 17:31:06 +0000 Subject: [PATCH 4/7] Remove invoice_number from phppos SQL migration script (#258) --- database/migrate_phppos_dist.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index 238f31799..fb08485a7 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -771,8 +771,7 @@ SELECT `receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quanti -- INSERT INTO `ospos_sales` (`sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, `invoice_number`) -SELECT `sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, `invoice_number` FROM `phppos`.phppos_sales; -UPDATE `ospos_sales` c1, `ospos_sales` c2 SET `c1`.`invoice_number` = NULL WHERE `c1`.`sale_id` > `c2`.`sale_id` AND `c1`.`invoice_number` = `c2`.`invoice_number`; +SELECT `sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, NULL FROM `phppos`.phppos_sales; -- -- Dumping data for table `ospos_sales_items` From 6599ea6678b1fd35dddc2a6ef4ee50fd8513fc14 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Thu, 4 Feb 2016 23:04:13 +0000 Subject: [PATCH 5/7] Fix and add data copy rules. Tested script (#258) --- database/migrate_phppos_dist.sql | 118 ++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 33 deletions(-) diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index fb08485a7..32c50661e 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -245,6 +245,7 @@ CREATE TABLE `ospos_item_kit_items` ( -- Dumping data for table `ospos_item_kit_items` -- + -- -------------------------------------------------------- -- @@ -663,6 +664,7 @@ CREATE TABLE `ospos_sessions` ( -- Dumping data for table `ospos_sessions` -- + -- -------------------------------------------------------- -- @@ -703,120 +705,170 @@ CREATE TABLE `ospos_suppliers` ( -- - -- -- This migration script should be run after creating tables with the regular database script and before applying the constraints. -- -- --- Dumping data for table `ospos_customers` +-- Copy data to table `ospos_app_config` -- -INSERT INTO `ospos_customers` (`person_id`, `account_number`, `taxable`, `deleted`) SELECT `person_id`, `account_number`, `taxable`, `deleted` FROM `phppos`.phppos_customers; + +DELETE FROM `ospos_app_config` WHERE `key` = 'address'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'address'; +DELETE FROM `ospos_app_config` WHERE `key` = 'company'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'company'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_1_name'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_1_name'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_1_rate'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_1_rate'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_2_name'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_2_name'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_2_rate'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_2_rate'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_rate'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_rate'; +DELETE FROM `ospos_app_config` WHERE `key` = 'email'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'email'; +DELETE FROM `ospos_app_config` WHERE `key` = 'fax'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'fax'; +DELETE FROM `ospos_app_config` WHERE `key` = 'phone'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'phone'; +DELETE FROM `ospos_app_config` WHERE `key` = 'return_policy'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'return_policy'; + +-- +-- Copy data to table `ospos_customers` +-- +INSERT INTO `ospos_customers` (`person_id`, `account_number`, `taxable`, `deleted`) +SELECT `person_id`, `account_number`, `taxable`, `deleted` FROM `phppos`.phppos_customers; UPDATE `ospos_customers` c1, `ospos_customers` c2 SET `c1`.`account_number` = NULL WHERE `c1`.`person_id` > `c2`.`person_id` AND `c1`.`account_number` = `c2`.`account_number`; -- --- Dumping data for table `ospos_employees` +-- Copy data to table `ospos_employees` -- -INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`) SELECT `username`, `password`, `person_id`, `deleted` FROM `phppos`.phppos_employees; +INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`) +SELECT `username`, `password`, `person_id`, `deleted` FROM `phppos`.phppos_employees; -- --- Dumping data for table `ospos_inventory` +-- Copy data to table `ospos_giftcards` +-- + +INSERT INTO `ospos_giftcards` (`giftcard_id`, `giftcard_number`, `value`, `deleted`, `person_id`) +SELECT `giftcard_id`, `giftcard_number`, `value`, `deleted`, `person_id` FROM `phppos`.phppos_giftcards; + +-- +-- Copy data to table `ospos_inventory` -- INSERT INTO `ospos_inventory` (`trans_id`, `trans_items`, `trans_user`, `trans_date`, `trans_comment`, `trans_location`, `trans_inventory`) SELECT `trans_id`, `trans_items`, `trans_user`, `trans_date`, `trans_comment`, 1, `trans_inventory` FROM `phppos`.phppos_inventory; -- --- Dumping data for table `ospos_items` +-- Copy data to table `ospos_items` -- -INSERT INTO `ospos_items` (`name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, `receiving_quantity`, `item_id`, `pic_id`, `allow_alt_description`, `is_serialized`, `deleted`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) SELECT `name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, 1, `item_id`, NULL, `allow_alt_description`, `is_serialized`, `deleted`, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 FROM `phppos`.phppos_items; +INSERT INTO `ospos_items` (`name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, `receiving_quantity`, `item_id`, `pic_id`, `allow_alt_description`, `is_serialized`, `deleted`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) +SELECT `name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, 1, `item_id`, NULL, `allow_alt_description`, `is_serialized`, `deleted`, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 FROM `phppos`.phppos_items; -- --- Dumping data for table `ospos_items_taxes` +-- Copy data to table `ospos_items_taxes` -- -INSERT INTO `ospos_items_taxes` (`item_id`, `name`, `percent`) SELECT `item_id`, `name`, `percent` FROM `phppos`.phppos_items_taxes; +INSERT INTO `ospos_items_taxes` (`item_id`, `name`, `percent`) +SELECT `item_id`, `name`, `percent` FROM `phppos`.phppos_items_taxes; -- --- Dumping data for table `ospos_item_kits` +-- Copy data to table `ospos_item_kits` -- --- TODO add query here +INSERT INTO `ospos_item_kits` (`item_kit_id`, `name`, `description`) +SELECT `item_kit_id`, `name`, `description` FROM `phppos`.phppos_item_kits; -- --- Dumping data for table `ospos_people` +-- Copy data to table `ospos_item_kit_items` +-- + +INSERT INTO `ospos_item_kit_items` (`item_kit_id`, `item_id`, `quantity`) +SELECT `item_kit_id`, `item_id`, `quantity` FROM `phppos`.phppos_item_kit_items; + +-- +-- Copy data to table `ospos_people` -- INSERT INTO `ospos_people` (`first_name`, `last_name`, `phone_number`, `email`, `address_1`, `address_2`, `city`, `state`, `zip`, `country`, `comments`, `person_id`) SELECT `first_name`, `last_name`, `phone_number`, `email`, `address_1`, `address_2`, `city`, `state`, `zip`, `country`, `comments`, `person_id` FROM `phppos`.phppos_people; -- --- Dumping data for table `ospos_receivings` +-- Copy data to table `ospos_receivings` -- INSERT INTO `ospos_receivings` (`receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, `invoice_number`) SELECT `receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, NULL FROM `phppos`.phppos_receivings; -- --- Dumping data for table `ospos_receivings_items` +-- Copy data to table `ospos_receivings_items` -- INSERT INTO `ospos_receivings_items` (`receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`) SELECT `receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent` FROM `phppos`.phppos_receivings_items; -- --- Dumping data for table `ospos_sales` +-- Copy data to table `ospos_sales` -- INSERT INTO `ospos_sales` (`sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, `invoice_number`) SELECT `sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, NULL FROM `phppos`.phppos_sales; -- --- Dumping data for table `ospos_sales_items` +-- Copy data to table `ospos_sales_items` -- INSERT INTO `ospos_sales_items` (`sale_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, `item_location`) SELECT `sale_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, 1 FROM `phppos`.phppos_sales_items; -- --- Dumping data for table `ospos_sales_items_taxes` +-- Copy data to table `ospos_sales_items_taxes` -- INSERT INTO `ospos_sales_items_taxes` (`sale_id`, `item_id`, `line`, `name`, `percent`) SELECT `sale_id`, `item_id`, `line`, `name`, `percent` FROM `phppos`.phppos_sales_items_taxes; --- -------------------------------------------------------- -- --- Table structure for table `ospos_sales_payments` --- - --- --- Dumping data for table `ospos_sales_payments` +-- Copy data to table `ospos_sales_payments` -- INSERT INTO `ospos_sales_payments` (`sale_id`, `payment_type`, `payment_amount`) SELECT `sale_id`, `payment_type`, `payment_amount` FROM `phppos`.phppos_sales_payments; -INSERT INTO `ospos_stock_locations` ( `deleted`, `location_name` ) VALUES (0, 'stock'); - -- --- Dumping data for table `ospos_item_quantities` +-- Copy data to table `ospos_item_quantities` -- -INSERT INTO `ospos_item_quantities` (`item_id`, `location_id`, `quantity`) SELECT `item_id`, 1, `quantity` FROM `phppos`.`phppos_items`; +INSERT INTO `ospos_item_quantities` (`item_id`, `location_id`, `quantity`) +SELECT `item_id`, 1, `quantity` FROM `phppos`.`phppos_items`; -- --- Dumping data for table `ospos_suppliers` +-- Copy data to table `ospos_suppliers` -- -INSERT INTO `ospos_suppliers` (`person_id`, `company_name`, `account_number`, `deleted`) SELECT `person_id`, `company_name`, `account_number`, `deleted` FROM `phppos`.phppos_suppliers; +INSERT INTO `ospos_suppliers` (`person_id`, `company_name`, `account_number`, `deleted`) +SELECT `person_id`, `company_name`, `account_number`, `deleted` FROM `phppos`.phppos_suppliers; + +-- -- Add constraints on copied data - --- --- Constraints for dumped tables -- -- From a0b422be3465922ade48bfc3da964fb15e91b64e Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Fri, 5 Feb 2016 09:05:57 +0000 Subject: [PATCH 6/7] Fix source script phppos_migrate.sql too (#258) --- database/migrate_phppos_dist.sql | 1 + database/phppos_migrate.sql | 118 +++++++++++++++++++++++-------- database/rename_tables.sql | 28 ++++++++ 3 files changed, 116 insertions(+), 31 deletions(-) create mode 100644 database/rename_tables.sql diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index 32c50661e..53e0c7c14 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -750,6 +750,7 @@ SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'return_pol -- -- Copy data to table `ospos_customers` -- + INSERT INTO `ospos_customers` (`person_id`, `account_number`, `taxable`, `deleted`) SELECT `person_id`, `account_number`, `taxable`, `deleted` FROM `phppos`.phppos_customers; UPDATE `ospos_customers` c1, `ospos_customers` c2 SET `c1`.`account_number` = NULL WHERE `c1`.`person_id` > `c2`.`person_id` AND `c1`.`account_number` = `c2`.`account_number`; diff --git a/database/phppos_migrate.sql b/database/phppos_migrate.sql index d81533d46..ccc285158 100644 --- a/database/phppos_migrate.sql +++ b/database/phppos_migrate.sql @@ -3,109 +3,165 @@ -- -- --- Dumping data for table `ospos_customers` +-- Copy data to table `ospos_app_config` -- -INSERT INTO `ospos_customers` (`person_id`, `account_number`, `taxable`, `deleted`) SELECT `person_id`, `account_number`, `taxable`, `deleted` FROM `phppos`.phppos_customers; + +DELETE FROM `ospos_app_config` WHERE `key` = 'address'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'address'; +DELETE FROM `ospos_app_config` WHERE `key` = 'company'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'company'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_1_name'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_1_name'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_1_rate'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_1_rate'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_2_name'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_2_name'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_2_rate'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_2_rate'; +DELETE FROM `ospos_app_config` WHERE `key` = 'default_tax_rate'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'default_tax_rate'; +DELETE FROM `ospos_app_config` WHERE `key` = 'email'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'email'; +DELETE FROM `ospos_app_config` WHERE `key` = 'fax'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'fax'; +DELETE FROM `ospos_app_config` WHERE `key` = 'phone'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'phone'; +DELETE FROM `ospos_app_config` WHERE `key` = 'return_policy'; +INSERT INTO `ospos_app_config` (`key`, `value`) +SELECT `key`, `value` FROM `phppos`.phppos_app_config WHERE `key` = 'return_policy'; + +-- +-- Copy data to table `ospos_customers` +-- + +INSERT INTO `ospos_customers` (`person_id`, `account_number`, `taxable`, `deleted`) +SELECT `person_id`, `account_number`, `taxable`, `deleted` FROM `phppos`.phppos_customers; UPDATE `ospos_customers` c1, `ospos_customers` c2 SET `c1`.`account_number` = NULL WHERE `c1`.`person_id` > `c2`.`person_id` AND `c1`.`account_number` = `c2`.`account_number`; -- --- Dumping data for table `ospos_employees` +-- Copy data to table `ospos_employees` -- -INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`) SELECT `username`, `password`, `person_id`, `deleted` FROM `phppos`.phppos_employees; +INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`) +SELECT `username`, `password`, `person_id`, `deleted` FROM `phppos`.phppos_employees; -- --- Dumping data for table `ospos_inventory` +-- Copy data to table `ospos_giftcards` +-- + +INSERT INTO `ospos_giftcards` (`giftcard_id`, `giftcard_number`, `value`, `deleted`, `person_id`) +SELECT `giftcard_id`, `giftcard_number`, `value`, `deleted`, `person_id` FROM `phppos`.phppos_giftcards; + +-- +-- Copy data to table `ospos_inventory` -- INSERT INTO `ospos_inventory` (`trans_id`, `trans_items`, `trans_user`, `trans_date`, `trans_comment`, `trans_location`, `trans_inventory`) SELECT `trans_id`, `trans_items`, `trans_user`, `trans_date`, `trans_comment`, 1, `trans_inventory` FROM `phppos`.phppos_inventory; -- --- Dumping data for table `ospos_items` +-- Copy data to table `ospos_items` -- -INSERT INTO `ospos_items` (`name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, `receiving_quantity`, `item_id`, `pic_id`, `allow_alt_description`, `is_serialized`, `deleted`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) SELECT `name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, 1, `item_id`, NULL, `allow_alt_description`, `is_serialized`, `deleted`, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 FROM `phppos`.phppos_items; +INSERT INTO `ospos_items` (`name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, `receiving_quantity`, `item_id`, `pic_id`, `allow_alt_description`, `is_serialized`, `deleted`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) +SELECT `name`, `category`, `supplier_id`, `item_number`, `description`, `cost_price`, `unit_price`, `reorder_level`, 1, `item_id`, NULL, `allow_alt_description`, `is_serialized`, `deleted`, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 FROM `phppos`.phppos_items; -- --- Dumping data for table `ospos_items_taxes` +-- Copy data to table `ospos_items_taxes` -- -INSERT INTO `ospos_items_taxes` (`item_id`, `name`, `percent`) SELECT `item_id`, `name`, `percent` FROM `phppos`.phppos_items_taxes; +INSERT INTO `ospos_items_taxes` (`item_id`, `name`, `percent`) +SELECT `item_id`, `name`, `percent` FROM `phppos`.phppos_items_taxes; -- --- Dumping data for table `ospos_item_kits` +-- Copy data to table `ospos_item_kits` -- --- TODO add query here +INSERT INTO `ospos_item_kits` (`item_kit_id`, `name`, `description`) +SELECT `item_kit_id`, `name`, `description` FROM `phppos`.phppos_item_kits; -- --- Dumping data for table `ospos_people` +-- Copy data to table `ospos_item_kit_items` +-- + +INSERT INTO `ospos_item_kit_items` (`item_kit_id`, `item_id`, `quantity`) +SELECT `item_kit_id`, `item_id`, `quantity` FROM `phppos`.phppos_item_kit_items; + +-- +-- Copy data to table `ospos_people` -- INSERT INTO `ospos_people` (`first_name`, `last_name`, `phone_number`, `email`, `address_1`, `address_2`, `city`, `state`, `zip`, `country`, `comments`, `person_id`) SELECT `first_name`, `last_name`, `phone_number`, `email`, `address_1`, `address_2`, `city`, `state`, `zip`, `country`, `comments`, `person_id` FROM `phppos`.phppos_people; -- --- Dumping data for table `ospos_receivings` +-- Copy data to table `ospos_receivings` -- INSERT INTO `ospos_receivings` (`receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, `invoice_number`) SELECT `receiving_time`, `supplier_id`, `employee_id`, `comment`, `receiving_id`, `payment_type`, NULL FROM `phppos`.phppos_receivings; -- --- Dumping data for table `ospos_receivings_items` +-- Copy data to table `ospos_receivings_items` -- INSERT INTO `ospos_receivings_items` (`receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`) SELECT `receiving_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent` FROM `phppos`.phppos_receivings_items; -- --- Dumping data for table `ospos_sales` +-- Copy data to table `ospos_sales` -- INSERT INTO `ospos_sales` (`sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, `invoice_number`) -SELECT `sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, `invoice_number` FROM `phppos`.phppos_sales; -UPDATE `ospos_sales` c1, `ospos_sales` c2 SET `c1`.`invoice_number` = NULL WHERE `c1`.`sale_id` > `c2`.`sale_id` AND `c1`.`invoice_number` = `c2`.`invoice_number`; +SELECT `sale_time`, `customer_id`, `employee_id`, `comment`, `sale_id`, NULL FROM `phppos`.phppos_sales; -- --- Dumping data for table `ospos_sales_items` +-- Copy data to table `ospos_sales_items` -- INSERT INTO `ospos_sales_items` (`sale_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, `item_location`) SELECT `sale_id`, `item_id`, `description`, `serialnumber`, `line`, `quantity_purchased`, `item_cost_price`, `item_unit_price`, `discount_percent`, 1 FROM `phppos`.phppos_sales_items; -- --- Dumping data for table `ospos_sales_items_taxes` +-- Copy data to table `ospos_sales_items_taxes` -- INSERT INTO `ospos_sales_items_taxes` (`sale_id`, `item_id`, `line`, `name`, `percent`) SELECT `sale_id`, `item_id`, `line`, `name`, `percent` FROM `phppos`.phppos_sales_items_taxes; --- -------------------------------------------------------- -- --- Table structure for table `ospos_sales_payments` --- - --- --- Dumping data for table `ospos_sales_payments` +-- Copy data to table `ospos_sales_payments` -- INSERT INTO `ospos_sales_payments` (`sale_id`, `payment_type`, `payment_amount`) SELECT `sale_id`, `payment_type`, `payment_amount` FROM `phppos`.phppos_sales_payments; -INSERT INTO `ospos_stock_locations` ( `deleted`, `location_name` ) VALUES (0, 'stock'); - -- --- Dumping data for table `ospos_item_quantities` +-- Copy data to table `ospos_item_quantities` -- -INSERT INTO `ospos_item_quantities` (`item_id`, `location_id`, `quantity`) SELECT `item_id`, 1, `quantity` FROM `phppos`.`phppos_items`; +INSERT INTO `ospos_item_quantities` (`item_id`, `location_id`, `quantity`) +SELECT `item_id`, 1, `quantity` FROM `phppos`.`phppos_items`; -- --- Dumping data for table `ospos_suppliers` +-- Copy data to table `ospos_suppliers` -- -INSERT INTO `ospos_suppliers` (`person_id`, `company_name`, `account_number`, `deleted`) SELECT `person_id`, `company_name`, `account_number`, `deleted` FROM `phppos`.phppos_suppliers; +INSERT INTO `ospos_suppliers` (`person_id`, `company_name`, `account_number`, `deleted`) +SELECT `person_id`, `company_name`, `account_number`, `deleted` FROM `phppos`.phppos_suppliers; + +-- -- Add constraints on copied data +-- + diff --git a/database/rename_tables.sql b/database/rename_tables.sql new file mode 100644 index 000000000..3e7c44b6f --- /dev/null +++ b/database/rename_tables.sql @@ -0,0 +1,28 @@ +-- +-- Rename tables +-- + +RENAME TABLE `ospos_app_config` TO `phppos_app_config`; +RENAME TABLE `ospos_customers` TO `phppos_customers`; +RENAME TABLE `ospos_employees` TO `phppos_employees`; +RENAME TABLE `ospos_giftcards` TO `phppos_giftcards`; +RENAME TABLE `ospos_inventory` TO `phppos_inventory`; +RENAME TABLE `ospos_items` TO `phppos_items`; +RENAME TABLE `ospos_items_taxes` TO `phppos_items_taxes`; +RENAME TABLE `ospos_item_kits` TO `phppos_item_kits`; +RENAME TABLE `ospos_item_kit_items` TO `phppos_item_kit_items`; +RENAME TABLE `ospos_modules` TO `phppos_modules`; +RENAME TABLE `ospos_people` TO `phppos_people`; +RENAME TABLE `ospos_permissions` TO `phppos_permissions`; +RENAME TABLE `ospos_receivings` TO `phppos_receivings`; +RENAME TABLE `ospos_receivings_items` TO `phppos_receivings_items`; +RENAME TABLE `ospos_sales` TO `phppos_sales`; +RENAME TABLE `ospos_sales_items` TO `phppos_sales_items`; +RENAME TABLE `ospos_sales_items_taxes` TO `phppos_sales_items_taxes`; +RENAME TABLE `ospos_sales_payments` TO `phppos_sales_payments`; +RENAME TABLE `ospos_sales_suspended` TO `phppos_sales_suspended`; +RENAME TABLE `ospos_sales_suspended_items` TO `phppos_sales_suspended_items`; +RENAME TABLE `ospos_sales_suspended_items_taxes` TO `phppos_sales_suspended_items_taxes`; +RENAME TABLE `ospos_sales_suspended_payments` TO `phppos_sales_suspended_payments`; +RENAME TABLE `ospos_sessions` TO `phppos_sessions`; +RENAME TABLE `ospos_suppliers` TO `phppos_suppliers`; From ea6fffc525b0258a9e55e9ca88690d704ea78eb0 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Fri, 5 Feb 2016 09:06:54 +0000 Subject: [PATCH 7/7] Add version liner so we remember which version the script works with (#258) --- database/migrate_phppos_dist.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index 53e0c7c14..321a9cd67 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -708,6 +708,8 @@ CREATE TABLE `ospos_suppliers` ( -- -- This migration script should be run after creating tables with the regular database script and before applying the constraints. -- +-- This script migrates data from phppos to ospos 2.3.4 +-- -- -- Copy data to table `ospos_app_config`