mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-30 04:19:13 +01:00
Remove old migrations
This commit is contained in:
parent
9ffe51f8c2
commit
9cc895d3bf
@ -25,7 +25,6 @@ const ENV_VERSION='1';
|
||||
//Config init
|
||||
{
|
||||
if (!getenv('SERVER_ADDRESS')) {
|
||||
EnvUpgrade::mysqlToDbPrefix();
|
||||
|
||||
$envFile = $options['env'];
|
||||
if (empty($envFile)) {
|
||||
|
@ -68,8 +68,6 @@ Example:
|
||||
|
||||
require_once __DIR__ . '/bootstrap.php';
|
||||
|
||||
SessionsMigration::move();
|
||||
SwooleToAmpMigration::check();
|
||||
StartUpFixes::fix();
|
||||
$mainProcessPid = getmypid();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,21 +7,5 @@ class StartUpFixes
|
||||
public static function fix(): void
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user