public function onSchemaDropTable(SchemaDropTableEventArgs $args) { if ($this->schemaManager->isPostGis2()) { return; } $table = $args->getTable(); $hasSpatialGeometryColumn = count($this->schemaManager->listSpatialGeometryColumns($table->getName())) > 0; if ($hasSpatialGeometryColumn) { $args->setSql("SELECT DropGeometryTable('" . $table->getName() . "')")->preventDefault(); } }
/** * @param \Doctrine\ORM\Tools\Event\SchemaDropTableEventArgs $args */ public function onSchemaDropTable(SchemaDropTableEventArgs $args) { $table = $args->getTable(); if ($table instanceof Table) { foreach ($table->getColumns() as $column) { if (!$column->getType() instanceof \Doctrine\Spatial\DBAL\Types\Type) { continue; } $args->preventDefault()->setSql("SELECT DropGeometryTable('" . $table->getQuotedName($args->getPlatform()) . "')"); break; } } else { // We should check here if the table contains geometry columns but we // don't have a connection availabe to query the geometry_columns table. } }