Remove old migrations

This commit is contained in:
Alexander Pankratov 2023-12-18 13:17:50 +01:00
parent 9ffe51f8c2
commit 9cc895d3bf
6 changed files with 0 additions and 83 deletions

View File

@ -25,7 +25,6 @@ const ENV_VERSION='1';
//Config init //Config init
{ {
if (!getenv('SERVER_ADDRESS')) { if (!getenv('SERVER_ADDRESS')) {
EnvUpgrade::mysqlToDbPrefix();
$envFile = $options['env']; $envFile = $options['env'];
if (empty($envFile)) { if (empty($envFile)) {

View File

@ -68,8 +68,6 @@ Example:
require_once __DIR__ . '/bootstrap.php'; require_once __DIR__ . '/bootstrap.php';
SessionsMigration::move();
SwooleToAmpMigration::check();
StartUpFixes::fix(); StartUpFixes::fix();
$mainProcessPid = getmypid(); $mainProcessPid = getmypid();

View File

@ -1,20 +0,0 @@
<?php
namespace TelegramApiServer\Migrations;
class EnvUpgrade
{
public static function mysqlToDbPrefix()
{
foreach (glob(ROOT_DIR . '/.env*') as $envFile) {
$text = file_get_contents($envFile);
if (str_contains($text, 'MYSQL_')) {
$text = preg_replace('/^MYSQL_/m', 'DB_', $text);
file_put_contents($envFile, $text);
}
}
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace TelegramApiServer\Migrations;
use TelegramApiServer\Files;
class SessionsMigration
{
public static function move($rootDir = ROOT_DIR)
{
foreach (glob("$rootDir/*" . Files::SESSION_EXTENSION) as $oldFile) {
preg_match(
'~^' . "{$rootDir}(?'session'.*)" . preg_quote(Files::SESSION_EXTENSION, '\\') . '$~',
$oldFile,
$matches
);
if ($session = $matches['session'] ?? null) {
$session = Files::getSessionFile($session);
Files::checkOrCreateSessionFolder($session);
rename($oldFile, "{$rootDir}/{$session}");
rename("{$oldFile}.lock", "{$rootDir}/{$session}.lock");
}
}
}
}

View File

@ -7,21 +7,5 @@ class StartUpFixes
public static function fix(): void public static function fix(): void
{ {
define('MADELINE_WORKER_TYPE', 'madeline-ipc'); define('MADELINE_WORKER_TYPE', 'madeline-ipc');
info('Removing ipc sockets from sessions to fix startup' . PHP_EOL);
foreach (glob(ROOT_DIR . '/sessions/*/*ipc') as $file) {
info("removing: $file");
unlink($file);
}
foreach (glob(ROOT_DIR . '/sessions/*/safe.php') as $file) {
$content = file_get_contents($file);
$oldLine = 'O:43:"danog\MadelineProto\Db\NullCache\MysqlArray"';
if (str_contains($content, $oldLine)) {
$content = str_replace('O:43:"danog\MadelineProto\Db\NullCache\MysqlArray"', 'O:33:"danog\MadelineProto\Db\MysqlArray"', $content);
file_put_contents($file, $content);
}
}
} }
} }

View File

@ -1,16 +0,0 @@
<?php
namespace TelegramApiServer\Migrations;
use UnexpectedValueException;
class SwooleToAmpMigration
{
public static function check()
{
if (getenv('SWOOLE_SERVER_ADDRESS')) {
throw new UnexpectedValueException('Please, update .env file! See .env.example');
}
}
}