mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-05-16 05:07:34 +08:00
migrations boolean() -> smallInteger()
This commit is contained in:
+30
-11
@@ -36,7 +36,7 @@ class Install
|
||||
protected array $requiredExtensions = [
|
||||
'ctype', 'curl', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml',
|
||||
'mysqli', 'bcmath', 'redis', 'gd', 'gmp', 'Zend OPcache', 'pcntl', 'posix', 'sockets', 'zip', 'intl',
|
||||
'sqlite3', 'pdo_sqlite'
|
||||
'sqlite3', 'pdo_sqlite', 'pdo_pgsql',
|
||||
];
|
||||
|
||||
protected array $conflictExtensions = [
|
||||
@@ -156,11 +156,18 @@ class Install
|
||||
|
||||
public function listExistsTable()
|
||||
{
|
||||
$sql = 'show tables';
|
||||
if (NexusDB::isMysql()) {
|
||||
$schema = nexus_env('DB_DATABASE');
|
||||
} else if (NexusDB::isPgsql()) {
|
||||
$schema = 'public';
|
||||
} else {
|
||||
throw new \RuntimeException('Invalid DB_CONNECTION');
|
||||
}
|
||||
$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '$schema'";
|
||||
$res = sql_query($sql);
|
||||
$data = [];
|
||||
while ($row = mysql_fetch_row($res)) {
|
||||
$data[] = $row[0];
|
||||
while ($row = mysql_fetch_assoc($res)) {
|
||||
$data[] = $row['table_name'];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@@ -554,7 +561,8 @@ class Install
|
||||
}
|
||||
$this->doLog("[CREATE ENV] final newData: " . json_encode($newData));
|
||||
unset($key, $value);
|
||||
mysql_connect($newData['DB_HOST'], $newData['DB_USERNAME'], $newData['DB_PASSWORD'], $newData['DB_DATABASE'], (int)$newData['DB_PORT']);
|
||||
//check
|
||||
mysql_connect($newData['DB_HOST'], $newData['DB_USERNAME'], $newData['DB_PASSWORD'], $newData['DB_DATABASE'], (int)$newData['DB_PORT'], $newData['DB_CONNECTION']);
|
||||
$redis = new \Redis();
|
||||
$redis->connect($newData['REDIS_HOST'], $newData['REDIS_PORT'] ?: 6379);
|
||||
if (!empty($data['REDIS_PASSWORD'])) {
|
||||
@@ -723,14 +731,25 @@ class Install
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getMysqlVersionInfo(): array
|
||||
public function getDatabaseVersionInfo(): array
|
||||
{
|
||||
$sql = 'select version() as v';
|
||||
$result = NexusDB::select($sql);
|
||||
$version = $result[0]['v'];
|
||||
$minVersion = '5.7.8';
|
||||
if (NexusDB::isMysql()) {
|
||||
$sql = 'select version() as v';
|
||||
$result = NexusDB::select($sql);
|
||||
$version = $result[0]['v'];
|
||||
$minVersion = '5.7.8';
|
||||
$dbType = "mysql";
|
||||
} else if (NexusDB::isPgsql()) {
|
||||
$sql = 'SHOW server_version;';
|
||||
$result = NexusDB::select($sql);
|
||||
$version = $result[0]['server_version'];
|
||||
$minVersion = '16.0';
|
||||
$dbType = "pgsql";
|
||||
} else {
|
||||
throw new \RuntimeException('Not supported database.');
|
||||
}
|
||||
$match = version_compare($version, $minVersion, '>=');
|
||||
return compact('version', 'match', 'minVersion');
|
||||
return compact('version', 'match', 'minVersion', 'dbType');
|
||||
}
|
||||
|
||||
public function getRedisVersionInfo(): array
|
||||
|
||||
@@ -103,7 +103,7 @@ if ($currentStep == 4) {
|
||||
$symbolicLinks = $settingTableRows['symbolic_links'];
|
||||
$tableRows = $settingTableRows['table_rows'];
|
||||
$pass = $settingTableRows['pass'];
|
||||
$mysqlInfo = $install->getMysqlVersionInfo();
|
||||
$mysqlInfo = $install->getDatabaseVersionInfo();
|
||||
$redisInfo = $install->getREdisVersionInfo();
|
||||
while ($isPost) {
|
||||
set_time_limit(300);
|
||||
@@ -189,10 +189,10 @@ if (
|
||||
echo sprintf('This step will merge <code>%s</code> to <code>%s</code>, then insert into database', $tableRows[1]['label'], $tableRows[0]['label']);
|
||||
echo '</div>';
|
||||
if (!$mysqlInfo['match']) {
|
||||
echo sprintf('<div class="text-red-700 pt-10">MySQL version: %s is too low, please use the newest version of 5.7 or above.</div>', $mysqlInfo['version']);
|
||||
echo sprintf('<div class="text-red-700 pt-10">%s version: %s is too low, please use the newest version of %s or above.</div>', $mysqlInfo['dbType'], $mysqlInfo['version'], $mysqlInfo['minVersion']);
|
||||
}
|
||||
if (!$redisInfo['match']) {
|
||||
echo sprintf('<div class="text-red-700 pt-10">Redis version: %s is too low, please use 2.0.0 or above.</div>', $redisInfo['version']);
|
||||
echo sprintf('<div class="text-red-700 pt-10">Redis version: %s is too low, please use %s or above.</div>', $redisInfo['version'], $redisInfo['minVersion']);
|
||||
}
|
||||
} elseif ($currentStep == 5) {
|
||||
echo $install->renderForm($userFormControls, '1/2', '1/4', '3/4');
|
||||
|
||||
@@ -156,7 +156,7 @@ if ($currentStep == 4) {
|
||||
$symbolicLinks = $settingTableRows['symbolic_links'];
|
||||
$tableRows = $settingTableRows['table_rows'];
|
||||
$pass = $settingTableRows['pass'];
|
||||
$mysqlInfo = $update->getMysqlVersionInfo();
|
||||
$mysqlInfo = $update->getDatabaseVersionInfo();
|
||||
$redisInfo = $update->getRedisVersionInfo();
|
||||
while ($isPost) {
|
||||
set_time_limit(300);
|
||||
|
||||
Reference in New Issue
Block a user