From 442af20815df109a3904d94dd78b3bc8b5883ea7 Mon Sep 17 00:00:00 2001 From: Steve Ireland Date: Wed, 12 Jun 2019 21:20:21 -0400 Subject: [PATCH] Add missing database constraints. --- .../migrations/20190612100000_dbfix.php | 20 +++++++++++++ .../migrations/sqlscripts/3.3.0_dbfix.sql | 30 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 application/migrations/20190612100000_dbfix.php create mode 100644 application/migrations/sqlscripts/3.3.0_dbfix.sql diff --git a/application/migrations/20190612100000_dbfix.php b/application/migrations/20190612100000_dbfix.php new file mode 100644 index 000000000..42dabafe5 --- /dev/null +++ b/application/migrations/20190612100000_dbfix.php @@ -0,0 +1,20 @@ + diff --git a/application/migrations/sqlscripts/3.3.0_dbfix.sql b/application/migrations/sqlscripts/3.3.0_dbfix.sql new file mode 100644 index 000000000..f2260daa2 --- /dev/null +++ b/application/migrations/sqlscripts/3.3.0_dbfix.sql @@ -0,0 +1,30 @@ +ALTER TABLE `ospos_sales_payments` ADD INDEX `employee_id` (`employee_id`); + +ALTER TABLE `ospos_sales_payments` + ADD CONSTRAINT `ospos_sales_payments_ibfk_2` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`); + +ALTER TABLE `ospos_customers` ADD INDEX `sales_tax_code_id` (`sales_tax_code_id`); + +ALTER TABLE `ospos_customers` + ADD CONSTRAINT `ospos_customers_ibfk_3` FOREIGN KEY (`sales_tax_code_id`) REFERENCES `ospos_tax_codes` (`tax_code_id`); + +ALTER TABLE `ospos_tax_rates` ADD INDEX `rate_tax_category_id` (`rate_tax_category_id`); + +ALTER TABLE `ospos_tax_rates` + ADD CONSTRAINT `ospos_tax_rates_ibfk_1` FOREIGN KEY (`rate_tax_category_id`) REFERENCES `ospos_tax_categories` (`tax_category_id`); + +ALTER TABLE `ospos_tax_rates` ADD INDEX `rate_tax_code_id` (`rate_tax_code_id`); + +ALTER TABLE `ospos_tax_rates` + ADD CONSTRAINT `ospos_tax_rates_ibfk_2` FOREIGN KEY (`rate_tax_code_id`) REFERENCES `ospos_tax_codes` (`tax_code_id`); + +ALTER TABLE `ospos_tax_rates` ADD INDEX `rate_jurisdiction_id` (`rate_jurisdiction_id`); + +ALTER TABLE `ospos_tax_rates` + ADD CONSTRAINT `ospos_tax_rates_ibfk_3` FOREIGN KEY (`rate_jurisdiction_id`) REFERENCES `ospos_tax_jurisdictions` (`jurisdiction_id`); + +ALTER TABLE `ospos_receivings` ADD INDEX `receiving_time` (`receiving_time`); + +ALTER TABLE `ospos_sales_payments` ADD INDEX `payment_time` (`payment_time`); + +ALTER TABLE `ospos_inventory` ADD INDEX `trans_date` (`trans_date`);