Implemented how the CreateDatabaseCommand checks if the database tables exist

This commit is contained in:
Alejandro Celaya 2019-08-05 10:16:58 +02:00
parent f78fa58cf1
commit b68e262eac

View File

@ -66,15 +66,19 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand
{ {
$schemaManager = $this->conn->getSchemaManager(); $schemaManager = $this->conn->getSchemaManager();
$databases = $schemaManager->listDatabases(); $databases = $schemaManager->listDatabases();
if (! contains($databases, '')) { $shlinkDatabase = $this->conn->getDatabase();
$schemaManager->createDatabase($this->conn->getDatabase());
if (! contains($databases, $shlinkDatabase)) {
$schemaManager->createDatabase($shlinkDatabase);
} }
} }
private function schemaExists(): bool private function schemaExists(): bool
{ {
// TODO Implement // If at least one of the shlink tables exist, we will consider the database exists somehow.
return false; // Any inconsistency will be taken care by the migrations
$schemaManager = $this->conn->getSchemaManager();
return ! empty($schemaManager->listTableNames());
} }
protected function getLockConfig(): LockedCommandConfig protected function getLockConfig(): LockedCommandConfig