szurubooru/scripts/upgrade.php

35 lines
966 B
PHP
Raw Normal View History

2014-09-14 16:16:15 +02:00
<?php
2014-09-25 11:51:51 +02:00
require_once(__DIR__
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'src'
2014-10-02 19:19:55 +02:00
. DIRECTORY_SEPARATOR . 'Bootstrap.php');
2014-09-14 16:16:15 +02:00
$testMode = false;
if (isset($argv))
{
foreach ($argv as $arg)
{
if ($arg === '--test')
$testMode = true;
}
}
if ($testMode)
{
$config = \Szurubooru\Injector::get(\Szurubooru\Config::class);
$config->database->dsn = $config->database->tests->dsn;
$config->database->user = $config->database->tests->user;
$config->database->password = $config->database->tests->password;
\Szurubooru\Injector::set(\Szurubooru\Config::class, $config);
$databaseConnection = \Szurubooru\Injector::get(\Szurubooru\DatabaseConnection::class);
$pdo = $databaseConnection->getPDO();
2014-11-21 10:03:08 +01:00
$pdo->exec('DROP DATABASE IF EXISTS szuru_test');
$pdo->exec('CREATE DATABASE szuru_test');
$pdo->exec('USE szuru_test');
}
$upgradeService = \Szurubooru\Injector::get(\Szurubooru\Services\UpgradeService::class);
2014-09-14 16:16:15 +02:00
$upgradeService->runUpgradesVerbose();