Esempio n. 1
0
 function toDialectString(IDialect $dialect)
 {
     //
     // FIXME move to IDialect
     //
     return 'DROP INDEX ' . $dialect->quoteIdentifier($this->index->getName()) . ($dialect->getDBDriver()->is(DBDriver::MYSQL) ? ' ON ' . $dialect->quoteIdentifier($this->index->getTable()->getName()) : '') . ($dialect->getDBDriver()->is(DBDriver::PGSQL) ? ' CASCADE ' : '') . ';';
 }
    /**
     * Dumps schema
     *
     * @param IOutput $writeStream stream to write the dump to
     * @param IDialect $dialect database dialect to use
     *
     * @return void
     */
    function make(IOutput $writeStream, IDialect $dialect)
    {
        $now = date('Y/m/d H:i');
        $product = PHOEBIUS_FULL_PRODUCT_NAME;
        $start = <<<EOT
--
-- {$product}
-- Generated at {$now} for {$dialect->getDBDriver()->getValue()}
--


EOT;
        $writeStream->write($start)->write($this->dbSchema->toDialectString($dialect));
    }
 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;';
 }