public function onSchemaAlterTableRemoveColumn(SchemaAlterTableRemoveColumnEventArgs $args)
{
$column = $args->getColumn();
if (!$this->isSpatialColumnType($column)) {
return;
}
if ('geometry' !== $column->getType()->getName() || $this->schemaManager->isPostGis2()) {
return;
}
$platform = $args->getPlatform();
$diff = $args->getTableDiff();
$table = new Identifier(false !== $diff->newName ? $diff->newName : $diff->name);
if ($column->getNotnull()) {
// Remove NOT NULL constraint from the field
$args->addSql(sprintf('ALTER TABLE %s ALTER %s SET DEFAULT NULL', $table->getQuotedName($platform), $column->getQuotedName($platform)));
}
// We use DropGeometryColumn() to also drop entries from the geometry_columns table
$args->addSql(sprintf("SELECT DropGeometryColumn('%s', '%s')", $table->getName(), $column->getName()));
$args->preventDefault();
}