1
0
mirror of synced 2025-01-18 06:21:40 +03:00

[DDC-1657] Prove that DBAL changes also work in ORM, not leading to drop sequence statements on postgresql with SERIAL pks.

This commit is contained in:
Benjamin Eberlei 2012-07-08 18:22:38 +02:00
parent eaae1f222f
commit 6e924f2a2c
2 changed files with 89 additions and 1 deletions

@ -1 +1 @@
Subproject commit 78dbf28923059545b24ba753c112560ad59ca89e
Subproject commit 79e894b4493937c0a6eae2e1c8206b188ac2eb7c

View File

@ -105,4 +105,92 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
}
$this->assertEquals(4, $dropSequenceSQLs, "Expect 4 sequences to be dropped.");
}
/**
* @group DDC-1657
*/
public function testUpdateSchemaWithPostgreSQLSchema()
{
$classes = array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Screen'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Avatar'),
);
try {
$this->_em->getConnection()->exec("CREATE SCHEMA stonewood");
} catch(\Exception $e) {
}
$tool = new SchemaTool($this->_em);
$tool->createSchema($classes);
$sql = $tool->getUpdateSchemaSql($classes);
$this->assertCount(0, $sql, implode("\n", $sql));
}
}
/**
* @Entity
* @Table(name="stonewood.screen")
*/
class DDC1657Screen
{
/**
* Identifier
* @var integer
*
* @Id
* @GeneratedValue(strategy="IDENTITY")
* @Column(name="pk", type="integer", nullable=false)
*/
private $pk;
/**
* Title
* @var string
*
* @Column(name="title", type="string", length=255, nullable=false)
*/
private $title;
/**
* Path
* @var string
*
* @Column(name="path", type="string", length=255, nullable=false)
*/
private $path;
/**
* Register date
* @var Date
*
* @Column(name="ddate", type="date", nullable=false)
*/
private $ddate;
/**
* Avatar
* @var Stonewood\Model\Entity\Avatar
*
* @ManyToOne(targetEntity="DDC1657Avatar")
* @JoinColumn(name="pk_avatar", referencedColumnName="pk", nullable=true, onDelete="CASCADE")
*/
private $avatar;
}
/**
* @Entity
* @Table(name="stonewood.avatar")
*/
class DDC1657Avatar
{
/**
* Identifier
* @var integer
*
* @Id
* @GeneratedValue(strategy="IDENTITY")
* @Column(name="pk", type="integer", nullable=false)
*/
private $pk;
}