mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 19:53:56 +00:00
Update schema.php
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Copyright (C) 2013 - 2016
|
Copyright (C) 2013 - 2019
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
@@ -634,30 +634,35 @@ if (!class_exists('schema')) {
|
|||||||
//get the field name
|
//get the field name
|
||||||
if (is_array($field['name'])) {
|
if (is_array($field['name'])) {
|
||||||
$field_name = $field['name']['text'];
|
$field_name = $field['name']['text'];
|
||||||
|
if (!$this->db_column_exists ($db_type, $db_name, $table_name, $field_name)) {
|
||||||
|
$field['exists'] == "false";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$field_name = $field['name'];
|
$field_name = $field['name'];
|
||||||
}
|
}
|
||||||
//find missing fields and add them
|
|
||||||
if ($field['exists'] == "false") {
|
//add or rename fields
|
||||||
$sql_update .= "ALTER TABLE ".$table_name." ADD ".$field_name." ".$field_type.";\n";
|
if ($this->db_column_exists ($db_type, $db_name, $table_name, $field['name']['deprecated'])) {
|
||||||
}
|
if ($db_type == "pgsql") {
|
||||||
//rename fields where the name has changed
|
$sql_update .= "ALTER TABLE ".$table_name." RENAME COLUMN ".$field['name']['deprecated']." to ".$field['name']['text'].";\n";
|
||||||
if (is_array($field['name'])) {
|
}
|
||||||
if ($this->db_column_exists ($db_type, $db_name, $table_name, $field['name']['deprecated'])) {
|
if ($db_type == "mysql") {
|
||||||
if ($db_type == "pgsql") {
|
$field_type = str_replace("AUTO_INCREMENT PRIMARY KEY", "", $field_type);
|
||||||
$sql_update .= "ALTER TABLE ".$table_name." RENAME COLUMN ".$field['name']['deprecated']." to ".$field['name']['text'].";\n";
|
$sql_update .= "ALTER TABLE ".$table_name." CHANGE ".$field['name']['deprecated']." ".$field['name']['text']." ".$field_type.";\n";
|
||||||
}
|
}
|
||||||
if ($db_type == "mysql") {
|
if ($db_type == "sqlite") {
|
||||||
$field_type = str_replace("AUTO_INCREMENT PRIMARY KEY", "", $field_type);
|
//a change has been made to the field name
|
||||||
$sql_update .= "ALTER TABLE ".$table_name." CHANGE ".$field['name']['deprecated']." ".$field['name']['text']." ".$field_type.";\n";
|
$apps[$x]['db'][$y]['rebuild'] = 'true';
|
||||||
}
|
|
||||||
if ($db_type == "sqlite") {
|
|
||||||
//a change has been made to the field name
|
|
||||||
$apps[$x]['db'][$y]['rebuild'] = 'true';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
//find missing fields and add them
|
||||||
|
if ($field['exists'] == "false") {
|
||||||
|
$sql_update .= "ALTER TABLE ".$table_name." ADD ".$field_name." ".$field_type.";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//change the data type if it has been changed
|
//change the data type if it has been changed
|
||||||
//if the data type in the app db array is different than the type in the database then change the data type
|
//if the data type in the app db array is different than the type in the database then change the data type
|
||||||
if ($upgrade_data_types) {
|
if ($upgrade_data_types) {
|
||||||
|
|||||||
Reference in New Issue
Block a user