/** * Generate the SQL queries needed to drop foreign key constraints from the table * * @param TableSchema $table The table instance the foreign key constraints are. * @return array SQL fragment. */ public function dropConstraintSql(TableSchema $table) { $sqlPattern = 'ALTER TABLE %s DROP CONSTRAINT %s;'; $sql = []; foreach ($table->constraints() as $name) { $constraint = $table->constraint($name); if ($constraint['type'] === TableSchema::CONSTRAINT_FOREIGN) { $tableName = $this->_driver->quoteIdentifier($table->name()); $constraintName = $this->_driver->quoteIdentifier($name); $sql[] = sprintf($sqlPattern, $tableName, $constraintName); } } return $sql; }