Пример #1
0
 /**
  * @group DBAL-224
  */
 public function testDropIndex()
 {
     $table = new Table("test");
     $table->addColumn('id', 'integer');
     $table->addIndex(array('id'), 'idx');
     $this->assertTrue($table->hasIndex('idx'));
     $table->dropIndex('idx');
     $this->assertFalse($table->hasIndex('idx'));
 }
 /**
  * @param Schema $schema
  * @param QueryBag $queries
  * @param string $tableName
  * @param string $columnName
  * @param array $options
  * @param string $className
  * @param Table $table
  */
 protected function renameIndex(Schema $schema, QueryBag $queries, $tableName, $columnName, $options, $className, $table)
 {
     $newColumnName = $options[ExtendOptionsManager::NEW_NAME_OPTION];
     $indexName = $this->nameGenerator->generateIndexNameForExtendFieldVisibleInGrid($className, $columnName);
     if ($table->hasIndex($indexName)) {
         $table->dropIndex($indexName);
         $newIndexName = $this->nameGenerator->generateIndexNameForExtendFieldVisibleInGrid($className, $newColumnName);
         $this->renameExtension->addIndex($schema, $queries, $tableName, [$newColumnName], $newIndexName);
     }
 }
Пример #3
0
 /**
  * @dataProvider getNormalizesAssetNames
  * @group DBAL-831
  */
 public function testNormalizesColumnNames($assetName)
 {
     $table = new Table('test');
     $table->addColumn($assetName, 'integer');
     $table->addIndex(array($assetName), $assetName);
     $table->addForeignKeyConstraint('test', array($assetName), array($assetName), array(), $assetName);
     $this->assertTrue($table->hasColumn($assetName));
     $this->assertTrue($table->hasColumn('foo'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Column', $table->getColumn($assetName));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Column', $table->getColumn('foo'));
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Index', $table->getIndex($assetName));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Index', $table->getIndex('foo'));
     $this->assertTrue($table->hasForeignKey($assetName));
     $this->assertTrue($table->hasForeignKey('foo'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $table->getForeignKey($assetName));
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $table->getForeignKey('foo'));
     $table->renameIndex($assetName, $assetName);
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $table->renameIndex($assetName, 'foo');
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $table->renameIndex('foo', $assetName);
     $this->assertTrue($table->hasIndex($assetName));
     $this->assertTrue($table->hasIndex('foo'));
     $table->renameIndex($assetName, 'bar');
     $this->assertFalse($table->hasIndex($assetName));
     $this->assertFalse($table->hasIndex('foo'));
     $this->assertTrue($table->hasIndex('bar'));
     $table->renameIndex('bar', $assetName);
     $table->dropColumn($assetName);
     $table->dropIndex($assetName);
     $table->removeForeignKey($assetName);
     $this->assertFalse($table->hasColumn($assetName));
     $this->assertFalse($table->hasColumn('foo'));
     $this->assertFalse($table->hasIndex($assetName));
     $this->assertFalse($table->hasIndex('foo'));
     $this->assertFalse($table->hasForeignKey($assetName));
     $this->assertFalse($table->hasForeignKey('foo'));
 }
Пример #4
0
 /**
  * Drop an index
  *
  * @param   string  $name  index name
  * @return  $this
  */
 public function dropIndex($name)
 {
     $this->table->dropIndex($name);
     return $this;
 }
 /**
  * @param \Doctrine\DBAL\Schema\Table $table
  * @param string $name
  */
 private function removeForeignKeyAndIndex(\Doctrine\DBAL\Schema\Table $table, $name)
 {
     $table->removeForeignKey($name);
     $table->dropIndex(str_replace('FK', 'IDX', $name));
 }