mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2025-12-15 19:06:03 +00:00
increase migrations verion
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
function init_db_schema() {
|
function init_db_schema()
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
|
|
||||||
@@ -1166,8 +1167,7 @@ function init_db_schema() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pdo->query("ALTER TABLE `" . $table . "` ADD `" . $column . "` " . $type);
|
$pdo->query("ALTER TABLE `" . $table . "` ADD `" . $column . "` " . $type);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$pdo->query("ALTER TABLE `" . $table . "` MODIFY COLUMN `" . $column . "` " . $type);
|
$pdo->query("ALTER TABLE `" . $table . "` MODIFY COLUMN `" . $column . "` " . $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1256,8 +1256,7 @@ function init_db_schema() {
|
|||||||
$pdo->query("ALTER TABLE `" . $table . "` DROP PRIMARY KEY");
|
$pdo->query("ALTER TABLE `" . $table . "` DROP PRIMARY KEY");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Create table if it is missing
|
// Create table if it is missing
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS `" . $table . "` (";
|
$sql = "CREATE TABLE IF NOT EXISTS `" . $table . "` (";
|
||||||
foreach ($properties['cols'] as $column => $type) {
|
foreach ($properties['cols'] as $column => $type) {
|
||||||
@@ -1269,20 +1268,17 @@ function init_db_schema() {
|
|||||||
$fields = "`" . implode("`, `", $key_values) . "`";
|
$fields = "`" . implode("`, `", $key_values) . "`";
|
||||||
$sql .= "PRIMARY KEY (" . $fields . ")" . ",";
|
$sql .= "PRIMARY KEY (" . $fields . ")" . ",";
|
||||||
}
|
}
|
||||||
}
|
} elseif (strtolower($key_type) == 'key') {
|
||||||
elseif (strtolower($key_type) == 'key') {
|
|
||||||
foreach ($key_content as $key_name => $key_values) {
|
foreach ($key_content as $key_name => $key_values) {
|
||||||
$fields = "`" . implode("`, `", $key_values) . "`";
|
$fields = "`" . implode("`, `", $key_values) . "`";
|
||||||
$sql .= "KEY `" . $key_name . "` (" . $fields . ")" . ",";
|
$sql .= "KEY `" . $key_name . "` (" . $fields . ")" . ",";
|
||||||
}
|
}
|
||||||
}
|
} elseif (strtolower($key_type) == 'unique') {
|
||||||
elseif (strtolower($key_type) == 'unique') {
|
|
||||||
foreach ($key_content as $key_name => $key_values) {
|
foreach ($key_content as $key_name => $key_values) {
|
||||||
$fields = "`" . implode("`, `", $key_values) . "`";
|
$fields = "`" . implode("`, `", $key_values) . "`";
|
||||||
$sql .= "UNIQUE KEY `" . $key_name . "` (" . $fields . ")" . ",";
|
$sql .= "UNIQUE KEY `" . $key_name . "` (" . $fields . ")" . ",";
|
||||||
}
|
}
|
||||||
}
|
} elseif (strtolower($key_type) == 'fkey') {
|
||||||
elseif (strtolower($key_type) == 'fkey') {
|
|
||||||
foreach ($key_content as $key_name => $key_values) {
|
foreach ($key_content as $key_name => $key_values) {
|
||||||
@list($table_ref, $field_ref) = explode('.', $key_values['ref']);
|
@list($table_ref, $field_ref) = explode('.', $key_values['ref']);
|
||||||
$sql .= "FOREIGN KEY `" . $key_name . "` (" . $key_values['col'] . ") REFERENCES `" . $table_ref . "` (`" . $field_ref . "`)
|
$sql .= "FOREIGN KEY `" . $key_name . "` (" . $key_values['col'] . ") REFERENCES `" . $table_ref . "` (`" . $field_ref . "`)
|
||||||
@@ -1296,7 +1292,6 @@ function init_db_schema() {
|
|||||||
}
|
}
|
||||||
// Reset table attributes
|
// Reset table attributes
|
||||||
$pdo->query("ALTER TABLE `" . $table . "` " . $properties['attr'] . ";");
|
$pdo->query("ALTER TABLE `" . $table . "` " . $properties['attr'] . ";");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recreate SQL views
|
// Recreate SQL views
|
||||||
@@ -1469,8 +1464,7 @@ function init_db_schema() {
|
|||||||
'msg' => 'db_init_complete'
|
'msg' => 'db_init_complete'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch (PDOException $e) {
|
|
||||||
if (php_sapi_name() == "cli") {
|
if (php_sapi_name() == "cli") {
|
||||||
echo "DB initialization failed: " . print_r($e, true) . PHP_EOL;
|
echo "DB initialization failed: " . print_r($e, true) . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
@@ -1509,8 +1503,7 @@ if (php_sapi_name() == "cli") {
|
|||||||
SELECT `c_uid`, `domain`, `c_name`, `c_password`, `c_cn`, `mail`, `aliases`, `ad_aliases`, `ext_acl`, `kind`, `multiple_bookings` from sogo_view");
|
SELECT `c_uid`, `domain`, `c_name`, `c_password`, `c_cn`, `mail`, `aliases`, `ad_aliases`, `ext_acl`, `kind`, `multiple_bookings` from sogo_view");
|
||||||
$stmt = $pdo->query("DELETE FROM _sogo_static_view WHERE `c_uid` NOT IN (SELECT `username` FROM `mailbox` WHERE `active` = '1');");
|
$stmt = $pdo->query("DELETE FROM _sogo_static_view WHERE `c_uid` NOT IN (SELECT `username` FROM `mailbox` WHERE `active` = '1');");
|
||||||
echo "Fixed _sogo_static_view" . PHP_EOL;
|
echo "Fixed _sogo_static_view" . PHP_EOL;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch ( Exception $e ) {
|
|
||||||
// Dunno
|
// Dunno
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1519,8 +1512,7 @@ if (php_sapi_name() == "cli") {
|
|||||||
$m->addServer('memcached', 11211);
|
$m->addServer('memcached', 11211);
|
||||||
$m->flush();
|
$m->flush();
|
||||||
echo "Cleaned up memcached" . PHP_EOL;
|
echo "Cleaned up memcached" . PHP_EOL;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch ( Exception $e ) {
|
|
||||||
// Dunno
|
// Dunno
|
||||||
}
|
}
|
||||||
init_db_schema();
|
init_db_schema();
|
||||||
|
|||||||
Reference in New Issue
Block a user