public function testCompareModifiedIndices() { $t1 = new Table(); $c1 = new Column('Foo'); $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); $c1->getDomain()->replaceSize(255); $c1->setNotNull(false); $t1->addColumn($c1); $i1 = new Index('Foo_Index'); $i1->addColumn($c1); $t1->addIndex($i1); $t2 = new Table(); $c2 = new Column('Foo'); $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); $c2->getDomain()->replaceScale(2); $c2->getDomain()->replaceSize(3); $c2->setNotNull(true); $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); $t2->addColumn($c2); $i2 = new Unique('Foo_Index'); $i2->addColumn($c2); $t2->addIndex($i2); $tc = new PropelTableComparator(); $tc->setFromTable($t1); $tc->setToTable($t2); $nbDiffs = $tc->compareIndices(); $tableDiff = $tc->getTableDiff(); $this->assertEquals(1, $nbDiffs); $this->assertEquals(1, count($tableDiff->getModifiedIndices())); $this->assertEquals(array('Foo_Index' => array($i1, $i2)), $tableDiff->getModifiedIndices()); }
public function providerForTestGetModifyTableIndicesDDL() { $schema1 = <<<EOF <database name="test"> \t<table name="foo"> \t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" /> \t\t<column name="bar" type="INTEGER" /> \t\t<column name="baz" type="VARCHAR" size="12" required="true" /> \t\t<index name="bar_FK"> \t\t\t<index-column name="bar"/> \t\t</index> \t\t<index name="bar_baz_FK"> \t\t\t<index-column name="bar"/> \t\t\t<index-column name="baz"/> \t\t</index> \t</table> </database> EOF; $schema2 = <<<EOF <database name="test"> \t<table name="foo"> \t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" /> \t\t<column name="bar" type="INTEGER" /> \t\t<column name="baz" type="VARCHAR" size="12" required="true" /> \t\t<index name="bar_baz_FK"> \t\t\t<index-column name="id"/> \t\t\t<index-column name="bar"/> \t\t\t<index-column name="baz"/> \t\t</index> \t\t<index name="baz_FK"> \t\t\t<index-column name="baz"/> \t\t</index> \t</table> </database> EOF; $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo'); $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo'); $tc = new PropelTableComparator(); $tc->setFromTable($t1); $tc->setToTable($t2); $tc->compareIndices(); return array(array($tc->getTableDiff())); }