Hey Parsifal,

What are you trying to do, is it like reversed engineering, from DB -> 
Entities or from Entities -> Database. 

It looks like you set up your entities and you want to create your database 
based on those, since ur calling orm:schema-tool:update. If so, can you 
show us how you set your uniqueConstraint on your entity? As you should set 
your uniqueConstraint as following on your entity:

<?php 

use Doctrine\ORM\Mapping AS ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="cities", 
uniqueConstraints={@ORM\UniqueConstraint(name="UNIQ_cityName", 
columns={"name"})}) 
*/ 
class City {
 // properties and getters/setters
}

Remember that a relation will create a FK constraint and that a PK is a unique 
value, so why bother using a uniqueConstraint? Would be nice if you could 
provide a little bit of your data model, like how did you set up your entities, 
parent -> child?

Greetings,
Kwido

Op dinsdag 28 juli 2015 13:04:10 UTC+2 schreef Parsifal:
>
>
> Hi,
>
> when I run orm:schema-tool:update it suggests this sql:
>
>  CREATE UNIQUE INDEX UNIQ_88C1634F8D9F6D38 ON child (parent_id);
>
> I run this sql on database and re-generate entities and it will be like:
>
> $metadata->setPrimaryTable(array(
>    'name' => 'child',
>    'uniqueConstraints' => 
>    array(
>    'UNIQ_88C1634F8D9F6D38' => 
>    array(
>     'columns' => 
>     array(
>     0 => 'parent_id',
>     ),
>    ),
>    ),
>
> then again I try to orm:validate-schema and it gives the error that 
> UNIQ_88C1634F8D9F6D38 already exists on table child, and it forces me to 
> remove it again both from entity and from db! why? what wrong I am doing?
>
> I probably have to add this child is unidirectional oneToOne to parent and 
> parent_id is both PK and FK to parent entity.
>
> please advice.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to