/**
  * Dump the constraints / foreign keys of all tables.
  *
  * The constraints should be created at the end to speed up the import of the dump.
  *
  * @param Table[]            $tables
  */
 public function dumpConstraints(array $tables)
 {
     foreach ($tables as $table) {
         foreach ($table->getForeignKeys() as $constraint) {
             $constraint = $this->platform->getCreateConstraintSQL($constraint, $table);
             $this->dumpOutput->writeln($constraint . ';');
         }
     }
 }
 public function testGeneratesConstraintCreationSql()
 {
     $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false);
     $sql = $this->_platform->getCreateConstraintSQL($idx, 'test');
     $this->assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql);
     $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true);
     $sql = $this->_platform->getCreateConstraintSQL($pk, 'test');
     $this->assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql);
     $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
     $sql = $this->_platform->getCreateConstraintSQL($fk, 'test');
     $this->assertEquals($this->getGenerateConstraintForeignKeySql($fk), $sql);
 }
 /**
  * Create a constraint on a table
  *
  * @param Constraint $constraint
  * @param string|Table $table
  */
 public function createConstraint(Constraint $constraint, $table)
 {
     $this->_execSql($this->_platform->getCreateConstraintSQL($constraint, $table));
 }
 /**
  * {@inheritDoc}
  */
 public function getCreateConstraintSQL(Constraint $constraint, $table)
 {
     $constraintSql = parent::getCreateConstraintSQL($constraint, $table);
     return $this->repositionContraintNameSQL($constraint, $constraintSql);
 }