Skip to content

Commit

Permalink
Check MariaDB version, update MySQL constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Jan 31, 2019
1 parent f4fb1ab commit 7ff9a90
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Install/Steps/ConnectToDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Flarum\Install\Step;
use Illuminate\Database\Connectors\MySqlConnector;
use Illuminate\Database\MySqlConnection;
use PDO;
use RangeException;

class ConnectToDatabase implements Step
Expand All @@ -39,10 +38,16 @@ public function run()
$config = $this->dbConfig->getConfig();
$pdo = (new MySqlConnector)->connect($config);

$version = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
$version = $pdo->query('SELECT VERSION()')->fetchColumn();

if (version_compare($version, '5.5.0', '<')) {
throw new RangeException('MySQL version too low. You need at least MySQL 5.5.');
if (str_contains($version, 'MariaDB')) {
if (version_compare($version, '10.0.5', '<')) {
throw new RangeException('MariaDB version too low. You need at least MariaDB 10.0.5');
}
} else {
if (version_compare($version, '5.6.0', '<')) {
throw new RangeException('MySQL version too low. You need at least MySQL 5.6.');
}
}

($this->store)(
Expand Down

0 comments on commit 7ff9a90

Please sign in to comment.