Merge pull request #459 from wrongecho/db-fix

Add contact_department varchar to db.sql & deploy fix via DB updater for recent fresh installs
This commit is contained in:
wrongecho 2022-05-01 21:51:23 +01:00 committed by GitHub
commit f0d497fec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 51 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");

50
db.sql
View File

@ -289,6 +289,7 @@ CREATE TABLE `contacts` (
`contact_id` int(11) NOT NULL AUTO_INCREMENT,
`contact_name` varchar(200) NOT NULL,
`contact_title` varchar(200) DEFAULT NULL,
`contact_department` varchar(200) DEFAULT NULL,
`contact_email` varchar(200) DEFAULT NULL,
`contact_phone` varchar(200) DEFAULT NULL,
`contact_extension` varchar(200) DEFAULT NULL,
@ -302,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`)
@ -351,40 +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 `document_tags`
--
DROP TABLE IF EXISTS `document_tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `document_tags` (
`tag_id` int(11) NOT NULL AUTO_INCREMENT,
`tag_name` varchar(30) NOT NULL,
`client_id` int(11) NOT NULL,
PRIMARY KEY (`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `documents`
--
@ -414,20 +380,6 @@ CREATE TABLE `documents` (
--
ALTER TABLE `documents` ADD FULLTEXT KEY `document_content_raw` (`document_content_raw`);
--
-- Table structure for table `documents_tagged`
--
DROP TABLE IF EXISTS `documents_tagged`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `documents_tagged` (
`document_id` int(11) NOT NULL,
`tag_id` int(11) NOT NULL,
PRIMARY KEY (`document_id`,`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `domains`
--