private function createDatabase() { if ($this->isInitialized) { return; } $databaseName = $this->databaseName = sprintf('%s_%d', $this->namePrefix, $this->processIdProvider->getPid()); $schemaManager = $this->connection->getSchemaManager(); $schemaManager->dropAndCreateDatabase($databaseName); $this->connection->exec("USE `{$databaseName}`"); $this->dataLoader->loadFiles($this->connection, $this->schemaFiles); $this->isInitialized = TRUE; }
private function createDatabase() { $databaseName = $this->namePrefix . '_shared'; $schemaManager = $this->connection->getSchemaManager(); $this->lock->acquire(__FILE__); $isDatabaseCreated = in_array($databaseName, $schemaManager->listDatabases(), TRUE); if ($isDatabaseCreated) { $this->lock->release(__FILE__); $this->connection->exec("USE `{$databaseName}`"); } else { try { $schemaManager->createDatabase($databaseName); $this->connection->exec("USE `{$databaseName}`"); $this->dataLoader->loadFiles($this->connection, $this->schemaFiles); } catch (\Exception $e) { $schemaManager->dropDatabase($databaseName); throw $e; } finally { $this->lock->release(__FILE__); } } }