public function install()
 {
     $messageSchema = $this->messagesSchemaProvider->getSchemaFor($this->messagesTableName);
     $endpointSchema = $this->endpointSchemaProvider->getSchemaFor($this->endpointsTableName);
     // is there a better way to atomically create in order to not compete with other endpoints?
     try {
         $this->connection->createTable($messageSchema->getTableName(), $messageSchema->getDefinition(), $messageSchema->getOptions());
     } catch (\Exception $e) {
     }
     try {
         $this->connection->createTable($endpointSchema->getTableName(), $endpointSchema->getDefinition(), $endpointSchema->getOptions());
     } catch (\Exception $e) {
     }
 }
 /**
  * @param string $endpointName
  *
  * @return int
  */
 public function fetchOrGenerateEndpointId($endpointName)
 {
     $endpointId = 0;
     $this->connection->transactional(function (LogicalConnection $connection) use($endpointName, &$endpointId) {
         $lookupHash = md5($endpointName);
         $endpointRecord = $connection->executeQuery("SELECT * FROM {$this->endpointsTableName} WHERE lookup_hash = ?", [$lookupHash])->fetch(\PDO::FETCH_ASSOC);
         if (!$endpointRecord) {
             $connection->insert($this->endpointsTableName, ['lookup_hash' => $lookupHash, 'name' => $endpointName]);
             $endpointId = (int) $connection->lastInsertId();
         } else {
             $endpointId = (int) $endpointRecord['id'];
         }
     });
     return $endpointId;
 }