dropColumn example

continue;
            }

            foreach ($table->getForeignKeys() as $foreignKey) {
                if (\str_starts_with($foreignKey->getName(), 'fk_ce_')) {
                    $table->removeForeignKey($foreignKey->getName());
                }
            }

            foreach ($table->getColumns() as $column) {
                if ($column->getComment() === self::COMMENT) {
                    $table->dropColumn($column->getName());
                }
            }
        }
    }
}

    protected function _alterTable(string $alterType, string $table$field)
    {
        switch ($alterType) {
            case 'DROP':
                $sqlTable = new Table($this->db, $this);

                $sqlTable->fromTable($table)
                    ->dropColumn($field)
                    ->run();

                return '';

            case 'CHANGE':
                (new Table($this->db, $this))
                    ->fromTable($table)
                    ->modifyColumn($field)
                    ->run();

                return null;

            
/** * {@inheritdoc} */
    public function delete($table$column$updateDependingTables = false)
    {
        $column = $this->formatColumnName($column);

        if (!$this->tableMapping->isTableColumn($table$column)) {
            throw new RuntimeException(sprintf('Table %s has no column with name %s', $table$column));
        }

        $this->schemaOperator->dropColumn($table$column);

        $repository = $this->entityManager->getRepository(Configuration::class);

        $entity = $repository->findOneBy([
            'tableName' => $table,
            'columnName' => $column,
        ]);

        if ($entity) {
            $this->entityManager->remove($entity);
            $this->entityManager->flush($entity);
        }
Home | Imprint | This part of the site doesn't use cookies.