From b68e262eac6aa59c873ddd17349ea8188a3b87b5 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 5 Aug 2019 10:16:58 +0200 Subject: [PATCH] Implemented how the CreateDatabaseCommand checks if the database tables exist --- module/CLI/src/Command/Db/CreateDatabaseCommand.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/module/CLI/src/Command/Db/CreateDatabaseCommand.php b/module/CLI/src/Command/Db/CreateDatabaseCommand.php index 4b4202a0..2703aefb 100644 --- a/module/CLI/src/Command/Db/CreateDatabaseCommand.php +++ b/module/CLI/src/Command/Db/CreateDatabaseCommand.php @@ -66,15 +66,19 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand { $schemaManager = $this->conn->getSchemaManager(); $databases = $schemaManager->listDatabases(); - if (! contains($databases, '')) { - $schemaManager->createDatabase($this->conn->getDatabase()); + $shlinkDatabase = $this->conn->getDatabase(); + + if (! contains($databases, $shlinkDatabase)) { + $schemaManager->createDatabase($shlinkDatabase); } } private function schemaExists(): bool { - // TODO Implement - return false; + // If at least one of the shlink tables exist, we will consider the database exists somehow. + // Any inconsistency will be taken care by the migrations + $schemaManager = $this->conn->getSchemaManager(); + return ! empty($schemaManager->listTableNames()); } protected function getLockConfig(): LockedCommandConfig