Details
Description
Given two databases, 'foo' and 'bar', with entities in /Entities/Foo/ annotated as follows:
/** * Test * * @Table(name="foo.test") * @Entity */
Create an EntityManager instance with
$connectionOptions = array(
'dbname' => 'Foo',
'driver' => 'pdo_mysql',
<..etc..>
);
Use EntityManager#getClassMetaData( "Entities\\Foo
Test" ) to pass to SchemaTool#createSchema() and Doctrine appropriately creates a database table foo.test
Use EntityManager#getClassMetaData( "Entities\\Foo
Test" ) to pass to SchemaTool#updateSchema() and Doctrine fails with Exception
-> SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'test' already exists
Inserting
die( print_r( $fromSchema, 1 ) . print_r( $toSchema, 1 ) . print_r( $schemaDiff, 1 ) );
into Doctrine/ORM/Tools/SchemaTool.php line 632 shows $fromSchema outputs
[_tables:protected] => Array
(
[test]
but $toSchema outputs
[_tables:protected] => Array
(
[foo.test]
which causes $schemaDiff to output
[newTables] => Array
(
[foo.test]
In summary, Doctrine/DBAL/Schema/Comparator considers foo.test a new table, because Doctrine/DBAL/Schema/AbstractSchemaManager lists its table as "test" rather than "foo.test".
Activity
| Field | Original Value | New Value |
|---|---|---|
| Description |
Given two databases, 'foo' and 'bar', with entities in /Entities/Foo/ annotated as follows: /** * Test * * @Table(name="foo.test") * @Entity */ Create an EntityManager instance with $connectionOptions( 'dbname' => 'Foo', 'driver' => 'pdo_mysql', <..etc..>); Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#createSchema() and Doctrine appropriately creates a database table foo.test Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#updateSchema() and Doctrine fails with Exception -> SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'test' already exists Inserting die( print_r( $fromSchema, 1 ) . print_r( $toSchema, 1 ) . print_r( $schemaDiff, 1 ) ); into Doctrine/ORM/Tools/SchemaTool.php line 632 shows $fromSchema outputs [_tables:protected] => Array ( [test] but $toSchema outputs [_tables:protected] => Array ( [foo.test] which causes $schemaDiff to output [newTables] => Array ( [foo.test] In summary, Doctrine/DBAL/Schema/Comparator considers foo.test a new table, because Doctrine/DBAL/Schema/AbstractSchemaManager lists its table as "test" rather than "foo.test". |
Given two databases, 'foo' and 'bar', with entities in /Entities/Foo/ annotated as follows: {noformat} /** * Test * * @Table(name="foo.test") * @Entity */ {noformat} Create an EntityManager instance with {noformat}$connectionOptions( 'dbname' => 'Foo', 'driver' => 'pdo_mysql', <..etc..>);{noformat} Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#createSchema() and Doctrine appropriately creates a database table foo.test Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#updateSchema() and Doctrine fails with Exception -> SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'test' already exists Inserting {noformat}die( print_r( $fromSchema, 1 ) . print_r( $toSchema, 1 ) . print_r( $schemaDiff, 1 ) );{noformat} into Doctrine/ORM/Tools/SchemaTool.php line 632 shows $fromSchema outputs {noformat}[_tables:protected] => Array ( [test]{noformat} but $toSchema outputs {noformat}[_tables:protected] => Array ( [foo.test]{noformat} which causes $schemaDiff to output {noformat}[newTables] => Array ( [foo.test]{noformat} In summary, Doctrine/DBAL/Schema/Comparator considers foo.test a new table, because Doctrine/DBAL/Schema/AbstractSchemaManager lists its table as "test" rather than "foo.test". |
| Description |
Given two databases, 'foo' and 'bar', with entities in /Entities/Foo/ annotated as follows: {noformat} /** * Test * * @Table(name="foo.test") * @Entity */ {noformat} Create an EntityManager instance with {noformat}$connectionOptions( 'dbname' => 'Foo', 'driver' => 'pdo_mysql', <..etc..>);{noformat} Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#createSchema() and Doctrine appropriately creates a database table foo.test Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#updateSchema() and Doctrine fails with Exception -> SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'test' already exists Inserting {noformat}die( print_r( $fromSchema, 1 ) . print_r( $toSchema, 1 ) . print_r( $schemaDiff, 1 ) );{noformat} into Doctrine/ORM/Tools/SchemaTool.php line 632 shows $fromSchema outputs {noformat}[_tables:protected] => Array ( [test]{noformat} but $toSchema outputs {noformat}[_tables:protected] => Array ( [foo.test]{noformat} which causes $schemaDiff to output {noformat}[newTables] => Array ( [foo.test]{noformat} In summary, Doctrine/DBAL/Schema/Comparator considers foo.test a new table, because Doctrine/DBAL/Schema/AbstractSchemaManager lists its table as "test" rather than "foo.test". |
Given two databases, 'foo' and 'bar', with entities in /Entities/Foo/ annotated as follows: {noformat} /** * Test * * @Table(name="foo.test") * @Entity */ {noformat} Create an EntityManager instance with {noformat}$connectionOptions = array( 'dbname' => 'Foo', 'driver' => 'pdo_mysql', <..etc..> );{noformat} Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#createSchema() and Doctrine appropriately creates a database table foo.test Use EntityManager#getClassMetaData( "Entities\\Foo\\Test" ) to pass to SchemaTool#updateSchema() and Doctrine fails with Exception -> SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'test' already exists Inserting {noformat}die( print_r( $fromSchema, 1 ) . print_r( $toSchema, 1 ) . print_r( $schemaDiff, 1 ) );{noformat} into Doctrine/ORM/Tools/SchemaTool.php line 632 shows $fromSchema outputs {noformat}[_tables:protected] => Array ( [test]{noformat} but $toSchema outputs {noformat}[_tables:protected] => Array ( [foo.test]{noformat} which causes $schemaDiff to output {noformat}[newTables] => Array ( [foo.test]{noformat} In summary, Doctrine/DBAL/Schema/Comparator considers foo.test a new table, because Doctrine/DBAL/Schema/AbstractSchemaManager lists its table as "test" rather than "foo.test". |
| Issue Type | Bug [ 1 ] | Improvement [ 4 ] |
| Workflow | jira [ 12614 ] | jira-feedback [ 13922 ] |
| Workflow | jira-feedback [ 13922 ] | jira-feedback2 [ 15786 ] |
| Workflow | jira-feedback2 [ 15786 ] | jira-feedback3 [ 18043 ] |