function toDialectString(IDialect $dialect) { $table = $dialect->quoteIdentifier($this->constraint->getTable()->getName()); $ct = $dialect->quoteIdentifier($this->constraint->getName()); if ($dialect->getDBDriver()->is(DBDriver::MYSQL)) { if ($this->constraint instanceof DBUniqueConstraint) { return 'ALTER TABLE ' . $table . ' DROP INDEX ' . $ct; } else { if ($this->constraint instanceof DBPrimaryKeyConstraint) { return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY'; } else { if ($this->constraint instanceof DBOneToOneConstraint || $this->constraint instanceof DBForeignKeyConstraint) { return 'ALTER TABLE ' . $table . ' DROP FOREIGN KEY ' . $ct; } } } Assert::isUnreachable('Do not know how to remove constraint %s from MySQL', get_class($this->constraint)); } return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $ct . ' CASCADE;'; }
function toDialectString(IDialect $dialect) { return 'ALTER TABLE ' . $dialect->quoteIdentifier($this->constraint->getTable()->getName()) . ' ADD ' . $this->constraint->toDialectString($dialect) . ';'; }