-
-
Save jmikola/1123476 to your computer and use it in GitHub Desktop.
$ opensky/console doctrine:schema:update --force | |
Updating database schema... | |
string(186) "CREATE TABLE Parameter (id INT AUTO_INCREMENT NOT NULL, key VARCHAR(255) NOT NULL, value VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_A86613B38A90ABA9 (key), PRIMARY KEY(id)) ENGINE = InnoDB" | |
string(2333) "#0 /home/jmikola/workspace/opensky/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php(618): PDO->query('CREATE TABLE Pa...') | |
#1 /home/jmikola/workspace/opensky/vendor/doctrine/lib/Doctrine/ORM/Tools/SchemaTool.php(641): Doctrine\DBAL\Connection->executeQuery('CREATE TABLE Pa...') | |
#2 /home/jmikola/workspace/opensky/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php(86): Doctrine\ORM\Tools\SchemaTool->updateSchema(Array, true) | |
#3 /home/jmikola/workspace/opensky/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php(59): Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand->executeSchemaCommand(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), Object(Doctrine\ORM\Tools\SchemaTool), Array) | |
#4 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/Proxy/UpdateSchemaDoctrineCommand.php(63): Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#5 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Component/Console/Command/Command.php(187): Symfony\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#6 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Component/Console/Application.php(191): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#7 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(75): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#8 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Component/Console/Application.php(117): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#9 /home/jmikola/workspace/opensky/opensky/console(16): Symfony\Component\Console\Application->run() | |
#10 {main}" |
<?php | |
use Doctrine\ORM\Mapping as ORM; | |
/** @ORM\Entity */ | |
class Parameter | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string", unique=true) | |
*/ | |
protected $key; | |
/** @ORM\Column(type="string") */ | |
protected $value; | |
} | |
@UniqueConstraint is a constraint for the Symfony2 validator component.
unique=true is part of the Doctrine mapping to create a unique constraint in the database.
Doctrine does not provide any validation before flushing. This is documented and intended. they consider that all frameworks out there have some validation tool so inventing a new one is pointless.
ah sorry, Confused UniqueConstraint and UniqueEntity.
unique=true works well for me. the difference is that it cannot be used to create multi fields constraints.
Btw, your output is not complete: the exception message is missing, there is only the stack trace.
Yup, I realized that after I took the snapshot :)
The exception message was just standard PDO stuff, with only a portion of the full SQL query - that's why I popped in to debug the full query and trace.
I'm really not sure why unique=true
failed for me. If this can't be reproduced by anyone on the Doctrine team I'll be happy to put it to rest.
http://www.doctrine-project.org/jira/browse/DDC-1317