DB Update: Adds an account_type_parent field to represent the parent type 1 being default and representing Assets, 2 Liabilities, 3 Equity this will be the new way to identify the parent account type instead of using account_type_id min and max values ex 10-19 was Assets, 20-29 was Liabilities, Equity being 30-39. This was improper as the primary key should never be static

This commit is contained in:
johnnyq 2023-10-20 14:56:40 -04:00
parent 8b9efb2e6d
commit fcc49c2b40
3 changed files with 23 additions and 15 deletions

View File

@ -1461,17 +1461,6 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.0'");
}
if (CURRENT_DATABASE_VERSION == '0.9.1') {
// Insert queries here required to update to DB version 0.9.2
mysqli_query($mysqli, "ALTER TABLE `invoices` ADD `invoice_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `invoice_due`");
mysqli_query($mysqli, "ALTER TABLE `recurring` ADD `recurring_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `recurring_status`");
mysqli_query($mysqli, "ALTER TABLE `quotes` ADD `quote_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `quote_status`");
// Then update the database to the next sequential version
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.2'");
}
// Be sure to change database_version.php to reflect the version you are updating to here
// Please add this same comment block to the bottom of this file, and update the version number.
// Uncomment Below Lines, to add additional database updates
@ -1484,6 +1473,24 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.1'");
}
if (CURRENT_DATABASE_VERSION == '0.9.1') {
// Insert queries here required to update to DB version 0.9.2
mysqli_query($mysqli, "ALTER TABLE `invoices` ADD `invoice_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `invoice_due`");
mysqli_query($mysqli, "ALTER TABLE `recurring` ADD `recurring_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `recurring_status`");
mysqli_query($mysqli, "ALTER TABLE `quotes` ADD `quote_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `quote_status`");
// Then update the database to the next sequential version
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.2'");
}
if (CURRENT_DATABASE_VERSION == '0.9.2') {
mysqli_query($mysqli, "ALTER TABLE `account_types` ADD `account_type_parent` INT(11) NOT NULL DEFAULT 1 AFTER `account_type_id`");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.3'");
}
//if (CURRENT_DATABASE_VERSION == '0.9.1') {
// Insert queries here required to update to DB version 0.9.0

View File

@ -5,5 +5,5 @@
* It is used in conjunction with database_updates.php
*/
DEFINE("LATEST_DATABASE_VERSION", "0.9.2");
DEFINE("LATEST_DATABASE_VERSION", "0.9.3");

7
db.sql
View File

@ -24,6 +24,7 @@ DROP TABLE IF EXISTS `account_types`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account_types` (
`account_type_id` int(11) NOT NULL AUTO_INCREMENT,
`account_type_parent` int(11) NOT NULL DEFAULT 1,
`account_type_name` varchar(255) NOT NULL,
`account_type_description` text DEFAULT NULL,
`account_type_created_at` datetime NOT NULL DEFAULT current_timestamp(),
@ -715,7 +716,7 @@ CREATE TABLE `invoices` (
`invoice_status` varchar(200) NOT NULL,
`invoice_date` date NOT NULL,
`invoice_due` date NOT NULL,
`invoice_discount_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
`invoice_discount_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
`invoice_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
`invoice_currency_code` varchar(200) NOT NULL,
`invoice_note` text DEFAULT NULL,
@ -938,9 +939,9 @@ CREATE TABLE `quotes` (
`quote_number` int(11) NOT NULL,
`quote_scope` varchar(255) DEFAULT NULL,
`quote_status` varchar(200) NOT NULL,
`quote_discount_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
`quote_date` date NOT NULL,
`quote_expire` date DEFAULT NULL,
`quote_discount_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
`quote_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
`quote_currency_code` varchar(200) NOT NULL,
`quote_note` text DEFAULT NULL,
@ -1743,4 +1744,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-10-16 17:19:49
-- Dump completed on 2023-10-20 14:53:11