diff --git a/database_updates.php b/database_updates.php index 19c21507..7f55d58b 100644 --- a/database_updates.php +++ b/database_updates.php @@ -187,10 +187,24 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ if(CURRENT_DATABASE_VERSION == '0.0.7'){ // Insert queries here required to update to DB version 0.0.8 + // Add contact_department column to tables without it (fresh installs) - this will cause an error if it already exists so catch and discard it + try{ + mysqli_query($mysqli, "ALTER TABLE contacts ADD contact_department VARCHAR(200) NULL AFTER contact_title"); + } catch(Exception $e) { + // Nothing + } + + // Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.8'"); + } + + if(CURRENT_DATABASE_VERSION == '0.0.8'){ + // Insert queries here required to update to DB version 0.0.9 + // ALTER queries..... // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.8'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.9'"); } // etc diff --git a/database_version.php b/database_version.php index 23587303..e221defc 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "0.0.7"); \ No newline at end of file +DEFINE("LATEST_DATABASE_VERSION", "0.0.8"); \ No newline at end of file diff --git a/db.sql b/db.sql index 567a7273..e8e4b846 100644 --- a/db.sql +++ b/db.sql @@ -303,7 +303,6 @@ CREATE TABLE `contacts` ( `contact_updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, `contact_archived_at` datetime DEFAULT NULL, `contact_location_id` int(11) DEFAULT NULL, - `contact_department_id` int(11) DEFAULT NULL, `contact_client_id` int(11) NOT NULL, `company_id` int(11) NOT NULL, PRIMARY KEY (`contact_id`) @@ -352,25 +351,6 @@ CREATE TABLE `custom_links` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `departments` --- - -DROP TABLE IF EXISTS `departments`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `departments` ( - `department_id` int(11) NOT NULL AUTO_INCREMENT, - `department_name` varchar(200) NOT NULL, - `department_created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `department_updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, - `department_archived_at` datetime DEFAULT NULL, - `department_client_id` int(11) NOT NULL, - `company_id` int(11) NOT NULL, - PRIMARY KEY (`department_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `documents` --