install base database in MigrateDatabaseCommand
This commit is contained in:
parent
6146641eed
commit
c7ab923563
@ -19,6 +19,8 @@ class MigrateDatabaseCommand extends Command
|
|||||||
{
|
{
|
||||||
$db = \Container::$dbConnection;
|
$db = \Container::$dbConnection;
|
||||||
|
|
||||||
|
$this->createBaseDb();
|
||||||
|
|
||||||
$db->startTransaction();
|
$db->startTransaction();
|
||||||
|
|
||||||
$success = [];
|
$success = [];
|
||||||
@ -62,10 +64,8 @@ class MigrateDatabaseCommand extends Command
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function readDir(string $type): array
|
private function createBaseDb()
|
||||||
{
|
{
|
||||||
$done = [];
|
|
||||||
|
|
||||||
$migrationTableExists = \Container::$dbConnection->query('SELECT count(*)
|
$migrationTableExists = \Container::$dbConnection->query('SELECT count(*)
|
||||||
FROM information_schema.tables
|
FROM information_schema.tables
|
||||||
WHERE table_schema = \'' . $_ENV['DB_NAME'] . '\'
|
WHERE table_schema = \'' . $_ENV['DB_NAME'] . '\'
|
||||||
@ -73,16 +73,25 @@ class MigrateDatabaseCommand extends Command
|
|||||||
->fetch(IResultSet::FETCH_NUM)[0];
|
->fetch(IResultSet::FETCH_NUM)[0];
|
||||||
|
|
||||||
if ($migrationTableExists != 0) {
|
if ($migrationTableExists != 0) {
|
||||||
$select = new Select(\Container::$dbConnection, 'migrations');
|
return;
|
||||||
$select->columns(['migration']);
|
}
|
||||||
$select->where('type', '=', $type);
|
|
||||||
$select->orderBy('migration');
|
|
||||||
|
|
||||||
$result = $select->execute();
|
\Container::$dbConnection->multiQuery(file_get_contents(ROOT . '/database/mapguesser.sql'));
|
||||||
|
}
|
||||||
|
|
||||||
while ($migration = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
private function readDir(string $type): array
|
||||||
$done[] = $migration['migration'];
|
{
|
||||||
}
|
$done = [];
|
||||||
|
|
||||||
|
$select = new Select(\Container::$dbConnection, 'migrations');
|
||||||
|
$select->columns(['migration']);
|
||||||
|
$select->where('type', '=', $type);
|
||||||
|
$select->orderBy('migration');
|
||||||
|
|
||||||
|
$result = $select->execute();
|
||||||
|
|
||||||
|
while ($migration = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
||||||
|
$done[] = $migration['migration'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = ROOT . '/database/migrations/' . $type;
|
$path = ROOT . '/database/migrations/' . $type;
|
||||||
|
Loading…
Reference in New Issue
Block a user