mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-30 03:09:22 +02:00
Fix migrations upgrade and downgrade
+ Add option to disable auto migrate
This commit is contained in:
parent
8aff9f36fb
commit
c24c93ad79
@ -237,7 +237,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function addColumn($table, $column, $definition): void {
|
public function addColumn($table, $column, $definition): void {
|
||||||
$this->exec('ALTER TABLE ' . $this->tableName($table) . ' ADD `access` ' . $this->fieldName($column) . ' ' . $definition . ';');
|
$this->exec('ALTER TABLE ' . $this->tableName($table) . ' ADD ' . $this->fieldName($column) . ' ' . $definition . ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modifyColumn($table, $column, $definition): void {
|
public function modifyColumn($table, $column, $definition): void {
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
*/
|
*/
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
|
if (!config('database_auto_migrate')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// database migrations
|
// database migrations
|
||||||
$tmp = '';
|
$tmp = '';
|
||||||
if(fetchDatabaseConfig('database_version', $tmp)) { // we got version
|
if(fetchDatabaseConfig('database_version', $tmp)) { // we got version
|
||||||
|
@ -45,7 +45,7 @@ $up = function () use ($db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$db->hasColumn(TABLE_PREFIX . 'monsters', 'rewardboss')) {
|
if(!$db->hasColumn(TABLE_PREFIX . 'monsters', 'rewardboss')) {
|
||||||
$db->addColumn(TABLE_PREFIX . 'monsters', 'rewardboss', "TINYINT(1) TINYINT(1) NOT NULL DEFAULT '0' AFTER `attackable`");
|
$db->addColumn(TABLE_PREFIX . 'monsters', 'rewardboss', "TINYINT(1) NOT NULL DEFAULT '0' AFTER `attackable`");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$db->hasColumn(TABLE_PREFIX . 'monsters', 'defense')) {
|
if(!$db->hasColumn(TABLE_PREFIX . 'monsters', 'defense')) {
|
||||||
|
@ -13,6 +13,6 @@ $up = function () use ($db) {
|
|||||||
|
|
||||||
$down = function () use ($db) {
|
$down = function () use ($db) {
|
||||||
if ($db->hasColumn(TABLE_PREFIX . 'visitors', 'user_agent')) {
|
if ($db->hasColumn(TABLE_PREFIX . 'visitors', 'user_agent')) {
|
||||||
$db->dropColumn(TABLE_PREFIX . 'monsters', 'user_agent');
|
$db->dropColumn(TABLE_PREFIX . 'visitors', 'user_agent');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,8 @@ $up = function () use ($db) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$down = function () use ($db) {
|
$down = function () use ($db) {
|
||||||
if ($db->hasTable(TABLE_PREFIX . 'settings')) {
|
// will break the aac
|
||||||
$db->dropTable(TABLE_PREFIX . 'settings');
|
//if ($db->hasTable(TABLE_PREFIX . 'settings')) {
|
||||||
}
|
// $db->dropTable(TABLE_PREFIX . 'settings');
|
||||||
|
//}
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @var OTS_DB_MySQL $db
|
||||||
|
*/
|
||||||
|
|
||||||
// 2023-11-11
|
// 2023-11-11
|
||||||
// execute highscores_ids_hidden once again, cause of settings
|
// execute highscores_ids_hidden once again, cause of settings
|
||||||
$up = function () {
|
$up = function () use ($db) {
|
||||||
require __DIR__ . '/20.php';
|
require __DIR__ . '/20.php';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -392,6 +392,13 @@ return [
|
|||||||
'default' => false,
|
'default' => false,
|
||||||
'is_config' => true,
|
'is_config' => true,
|
||||||
],
|
],
|
||||||
|
'database_auto_migrate' => [
|
||||||
|
'name' => 'Database Auto Migrate',
|
||||||
|
'desc' => 'Migrate database to latest version in myaac, automatically.',
|
||||||
|
'type' => 'boolean',
|
||||||
|
'default' => true,
|
||||||
|
'is_config' => true,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'type' => 'category',
|
'type' => 'category',
|
||||||
'title' => 'Mailing',
|
'title' => 'Mailing',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user