From 7b09e0e430c7708969c6da3c97c779208927da1b Mon Sep 17 00:00:00 2001 From: hugh-unicenta Date: Fri, 23 Jun 2023 17:37:23 +0100 Subject: [PATCH] 5.0.1 migration scripts --- .../pos/scripts/Derby-upgrade_master.sql | 65 ++++++++++++++++++- .../pos/scripts/MariaDB-upgrade_master.sql | 61 ++++++++++++++++- .../pos/scripts/MySQL-upgrade_master.sql | 61 ++++++++++++++++- 3 files changed, 184 insertions(+), 3 deletions(-) diff --git a/src/main/resources/com/unicenta/pos/scripts/Derby-upgrade_master.sql b/src/main/resources/com/unicenta/pos/scripts/Derby-upgrade_master.sql index b82820f..9dcafbf 100644 --- a/src/main/resources/com/unicenta/pos/scripts/Derby-upgrade_master.sql +++ b/src/main/resources/com/unicenta/pos/scripts/Derby-upgrade_master.sql @@ -1,7 +1,70 @@ +-- CLEAR THE DECKS +DELETE FROM sharedtickets; + +-- Switch OFF table foreign key relationships +set foreign_key_checks = 0; + +-- RECREATE applications table +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + + +-- SYSTEM +DELETE FROM resources WHERE name = 'script.posapps'; + + +DELETE FROM resources WHERE id = '0'; +DELETE FROM resources WHERE id = '00'; +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml} WHERE name = 'Ticket.Buttons'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml} WHERE name = 'Printer.Ticket'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Close.xml} WHERE name = 'Ticket.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Cash.Close.xml} WHERE name = 'Cash.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.created.xml} WHERE name = 'Customer.Created'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.deleted.xml} WHERE name = 'Customer.Deleted'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated'; +COMMIT; + UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Linediscount.txt} WHERE name = 'script.Linediscount'; +COMMIT; UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Totaldiscount.txt} WHERE name = 'script.Totaldiscount'; +COMMIT; UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.multibuy.txt} WHERE name = 'script.multibuy'; +COMMIT; -UPDATE applications SET version = $APP_VERSION{} WHERE id = $APP_ID{}; \ No newline at end of file +-- ROLES +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +DELETE FROM roles WHERE id = '1'; +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +DELETE FROM roles WHERE id = '2'; +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); + + +-- Switch ON table foreign key relationships +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); + +COMMIT; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MariaDB-upgrade_master.sql b/src/main/resources/com/unicenta/pos/scripts/MariaDB-upgrade_master.sql index ee87d92..9dcafbf 100644 --- a/src/main/resources/com/unicenta/pos/scripts/MariaDB-upgrade_master.sql +++ b/src/main/resources/com/unicenta/pos/scripts/MariaDB-upgrade_master.sql @@ -1,3 +1,49 @@ +-- CLEAR THE DECKS +DELETE FROM sharedtickets; + +-- Switch OFF table foreign key relationships +set foreign_key_checks = 0; + +-- RECREATE applications table +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + + +-- SYSTEM +DELETE FROM resources WHERE name = 'script.posapps'; + + +DELETE FROM resources WHERE id = '0'; +DELETE FROM resources WHERE id = '00'; +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml} WHERE name = 'Ticket.Buttons'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml} WHERE name = 'Printer.Ticket'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Close.xml} WHERE name = 'Ticket.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Cash.Close.xml} WHERE name = 'Cash.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.created.xml} WHERE name = 'Customer.Created'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.deleted.xml} WHERE name = 'Customer.Deleted'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated'; +COMMIT; + UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Linediscount.txt} WHERE name = 'script.Linediscount'; COMMIT; @@ -7,5 +53,18 @@ COMMIT; UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.multibuy.txt} WHERE name = 'script.multibuy'; COMMIT; -UPDATE applications SET version = $APP_VERSION{} WHERE id = $APP_ID{}; +-- ROLES +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +DELETE FROM roles WHERE id = '1'; +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +DELETE FROM roles WHERE id = '2'; +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); + + +-- Switch ON table foreign key relationships +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); + COMMIT; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade_master.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade_master.sql index ee92fe5..9dcafbf 100644 --- a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade_master.sql +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade_master.sql @@ -1,3 +1,49 @@ +-- CLEAR THE DECKS +DELETE FROM sharedtickets; + +-- Switch OFF table foreign key relationships +set foreign_key_checks = 0; + +-- RECREATE applications table +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + + +-- SYSTEM +DELETE FROM resources WHERE name = 'script.posapps'; + + +DELETE FROM resources WHERE id = '0'; +DELETE FROM resources WHERE id = '00'; +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml} WHERE name = 'Ticket.Buttons'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml} WHERE name = 'Printer.Ticket'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Close.xml} WHERE name = 'Ticket.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Cash.Close.xml} WHERE name = 'Cash.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.created.xml} WHERE name = 'Customer.Created'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.deleted.xml} WHERE name = 'Customer.Deleted'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated'; +COMMIT; + UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Linediscount.txt} WHERE name = 'script.Linediscount'; COMMIT; @@ -7,5 +53,18 @@ COMMIT; UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.multibuy.txt} WHERE name = 'script.multibuy'; COMMIT; -UPDATE applications SET version = $APP_VERSION{} WHERE id = $APP_NAME{}; +-- ROLES +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +DELETE FROM roles WHERE id = '1'; +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +DELETE FROM roles WHERE id = '2'; +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); + + +-- Switch ON table foreign key relationships +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); + COMMIT; \ No newline at end of file