Dumplie\Metadata\Infrastructure\Doctrine\Dbal\DoctrineStorageException::tableAlreadyExists PHP Method

tableAlreadyExists() public static method

public static tableAlreadyExists ( string $table ) : DoctrineStorageException
$table string
return DoctrineStorageException
    public static function tableAlreadyExists(string $table) : DoctrineStorageException
    {
        return new static(sprintf('Table "%s" already exists', $table));
    }

Usage Example

Example #1
0
 /**
  * @param Schema $schema
  *
  * @throws DoctrineStorageException
  */
 public function create(Schema $schema)
 {
     $currentDbSchema = $this->connection->getSchemaManager()->createSchema();
     $dbSchema = new DBALSchema($currentDbSchema->getTables(), $currentDbSchema->getSequences(), $this->connection->getSchemaManager()->createSchemaConfig());
     foreach ($schema->types() as $type) {
         $tableName = $this->tableName($schema->name(), $type->name());
         if ($dbSchema->hasTable($tableName)) {
             throw DoctrineStorageException::tableAlreadyExists($tableName);
         }
         $this->createTable($dbSchema, $schema->name(), $type);
     }
     $queries = $dbSchema->toSql($this->connection->getDatabasePlatform());
     $this->executeQueries($queries);
 }