mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Update schema.php
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2013 - 2014
|
||||
Copyright (C) 2013 - 2016
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -63,8 +63,8 @@ if (!class_exists('schema')) {
|
||||
if (isset($app['db']) && count($app['db'])) {
|
||||
foreach ($app['db'] as $row) {
|
||||
//create the sql string
|
||||
$table_name = $row['table'];
|
||||
$sql = "CREATE TABLE " . $row['table'] . " (\n";
|
||||
$table_name = $row['table']['name'];
|
||||
$sql = "CREATE TABLE " . $row['table']['name'] . " (\n";
|
||||
$field_count = 0;
|
||||
foreach ($row['fields'] as $field) {
|
||||
if (isset($field['deprecated']) and ($field['deprecated'] == "true")) {
|
||||
@@ -350,8 +350,8 @@ if (!class_exists('schema')) {
|
||||
public function db_create_table ($apps, $db_type, $table) {
|
||||
if (is_array($apps)) foreach ($apps as $x => &$app) {
|
||||
if (is_array($app['db'])) foreach ($app['db'] as $y => $row) {
|
||||
if ($row['table'] == $table) {
|
||||
$sql = "CREATE TABLE " . $row['table'] . " (\n";
|
||||
if ($row['table']['name'] == $table) {
|
||||
$sql = "CREATE TABLE " . $row['table']['name'] . " (\n";
|
||||
$field_count = 0;
|
||||
if (is_array($row['fields'])) foreach ($row['fields'] as $field) {
|
||||
if ($field['deprecated'] == "true") {
|
||||
@@ -389,8 +389,8 @@ if (!class_exists('schema')) {
|
||||
global $db_name;
|
||||
foreach ($apps as $x => &$app) {
|
||||
foreach ($app['db'] as $y => $row) {
|
||||
if ($row['table'] == $table) {
|
||||
$sql = "INSERT INTO " . $row['table'] . " (";
|
||||
if ($row['table']['name'] == $table) {
|
||||
$sql = "INSERT INTO " . $row['table']['name'] . " (";
|
||||
$field_count = 0;
|
||||
foreach ($row['fields'] as $field) {
|
||||
if ($field['deprecated'] == "true") {
|
||||
@@ -523,11 +523,22 @@ if (!class_exists('schema')) {
|
||||
$sql = '';
|
||||
foreach ($apps as $x => &$app) {
|
||||
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
||||
if (is_array($row['table'])) {
|
||||
$table_name = $row['table']['text'];
|
||||
if (isset($row['table']['name'])) {
|
||||
if (is_array($row['table']['name'])) {
|
||||
$table_name = $row['table']['name']['text'];
|
||||
}
|
||||
else {
|
||||
$table_name = $row['table']['name'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$table_name = $row['table'];
|
||||
//old array syntax
|
||||
if (is_array($row['table'])) {
|
||||
$table_name = $row['table']['text'];
|
||||
}
|
||||
else {
|
||||
$table_name = $row['table'];
|
||||
}
|
||||
}
|
||||
if (strlen($table_name) > 0) {
|
||||
//check if the table exists
|
||||
@@ -574,25 +585,25 @@ if (!class_exists('schema')) {
|
||||
//add missing tables and fields
|
||||
foreach ($apps as $x => &$app) {
|
||||
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
||||
if (is_array($row['table'])) {
|
||||
$table_name = $row['table']['text'];
|
||||
if (!$this->db_table_exists($db_type, $db_name, $row['table']['text'])) {
|
||||
if (is_array($row['table']['name'])) {
|
||||
$table_name = $row['table']['name']['text'];
|
||||
if (!$this->db_table_exists($db_type, $db_name, $row['table']['name']['text'])) {
|
||||
$row['exists'] = "true"; //testing
|
||||
//if (db_table_exists($db_type, $db_name, $row['table']['deprecated'])) {
|
||||
//if (db_table_exists($db_type, $db_name, $row['table']['name']['deprecated'])) {
|
||||
if ($db_type == "pgsql") {
|
||||
$sql_update .= "ALTER TABLE ".$row['table']['deprecated']." RENAME TO ".$row['table']['text'].";\n";
|
||||
$sql_update .= "ALTER TABLE ".$row['table']['name']['deprecated']." RENAME TO ".$row['table']['name']['text'].";\n";
|
||||
}
|
||||
if ($db_type == "mysql") {
|
||||
$sql_update .= "RENAME TABLE ".$row['table']['deprecated']." TO ".$row['table']['text'].";\n";
|
||||
$sql_update .= "RENAME TABLE ".$row['table']['name']['deprecated']." TO ".$row['table']['name']['text'].";\n";
|
||||
}
|
||||
if ($db_type == "sqlite") {
|
||||
$sql_update .= "ALTER TABLE ".$row['table']['deprecated']." RENAME TO ".$row['table']['text'].";\n";
|
||||
$sql_update .= "ALTER TABLE ".$row['table']['name']['deprecated']." RENAME TO ".$row['table']['name']['text'].";\n";
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$table_name = $row['table'];
|
||||
$table_name = $row['table']['name'];
|
||||
}
|
||||
//check if the table exists
|
||||
if ($row['exists'] == "true") {
|
||||
@@ -701,8 +712,8 @@ if (!class_exists('schema')) {
|
||||
}
|
||||
else {
|
||||
//create table
|
||||
if (!is_array($row['table'])) {
|
||||
$sql_update .= $this->db_create_table($apps, $db_type, $row['table']);
|
||||
if (!is_array($row['table']['name'])) {
|
||||
$sql_update .= $this->db_create_table($apps, $db_type, $row['table']['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -710,11 +721,11 @@ if (!class_exists('schema')) {
|
||||
//rebuild and populate the table
|
||||
foreach ($apps as $x => &$app) {
|
||||
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
||||
if (is_array($row['table'])) {
|
||||
$table_name = $row['table']['text'];
|
||||
if (is_array($row['table']['name'])) {
|
||||
$table_name = $row['table']['name']['text'];
|
||||
}
|
||||
else {
|
||||
$table_name = $row['table'];
|
||||
$table_name = $row['table']['name'];
|
||||
}
|
||||
if ($row['rebuild'] == "true") {
|
||||
if ($db_type == "sqlite") {
|
||||
@@ -767,11 +778,11 @@ if (!class_exists('schema')) {
|
||||
$sql = '';
|
||||
foreach ($apps as &$app) {
|
||||
if (isset($app['db'])) foreach ($app['db'] as $row) {
|
||||
if (is_array($row['table'])) {
|
||||
$table_name = $row['table']['text'];
|
||||
if (is_array($row['table']['name'])) {
|
||||
$table_name = $row['table']['name']['text'];
|
||||
}
|
||||
else {
|
||||
$table_name = $row['table'];
|
||||
$table_name = $row['table']['name'];
|
||||
}
|
||||
$response .= "<tr>\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user