Add contact_department column for anyone that installed since it was added

This commit is contained in:
Marcus Hill 2022-05-01 21:46:05 +01:00
parent 6f9439a85e
commit d7381d5e06
3 changed files with 16 additions and 22 deletions

View File

@ -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

View File

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

20
db.sql
View File

@ -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`
--