/** * @group DBAL-204 */ public function testCleanupForeignKeysDifferentOrder() { $config = new SchemaConfig(); $config->setName("test"); $schema = new Schema(array(), array(), $config); $testTable = $schema->createTable("test.test"); $testTable->addColumn('id', 'integer'); $fooTable = $schema->createTable("foo.bar"); $fooTable->addColumn('id', 'integer'); $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id")); $schema->visit(new RemoveNamespacedAssets()); $sql = $schema->toSql(new MySqlPlatform()); $this->assertEquals(1, count($sql), "Just one CREATE TABLE statement, no foreign key and table to foo.bar"); }
public function testMultiTenantNonPrimaryKey() { $platform = new SQLAzurePlatform(); $visitor = new MultiTenantVisitor(); $schema = new Schema(); $foo = $schema->createTable('foo'); $foo->addColumn('id', 'string'); $foo->addColumn('created', 'datetime'); $foo->setPrimaryKey(array('id')); $foo->addIndex(array('created'), 'idx'); $foo->getPrimaryKey()->addFlag('nonclustered'); $foo->getIndex('idx')->addFlag('clustered'); $schema->visit($visitor); $this->assertEquals(array('id'), $foo->getPrimaryKey()->getColumns()); $this->assertTrue($foo->hasColumn('tenant_id')); $this->assertEquals(array('created', 'tenant_id'), $foo->getIndex('idx')->getColumns()); }
/** * @param Schema $schema * @param OutputInterface $output */ protected function dumpPhpSchema(Schema $schema, OutputInterface $output) { $visitor = $this->getContainer()->get('oro_migration.tools.schema_dumper'); $schema->visit($visitor); $output->writeln($visitor->dump($this->allowedTables, $this->namespace, $this->className, $this->version, $this->extendedFieldOptions)); }
public function testFixSchema_AddExplicitIndexForForeignKey() { $schema = new Schema(); $tableA = $schema->createTable('foo'); $tableA->addColumn('id', 'integer'); $tableB = $schema->createTable('bar'); $tableB->addColumn('id', 'integer'); $tableB->addColumn('foo_id', 'integer'); $tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id')); $this->assertEquals(0, count($tableB->getIndexes())); $schema->visit(new \Doctrine\DBAL\Schema\Visitor\FixSchema(true)); $this->assertEquals(1, count($tableB->getIndexes())); $indexes = $tableB->getIndexes(); $index = current($indexes); $this->assertTrue($index->hasColumnAtPosition('foo_id', 0)); }