{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/4502","labels_url":"https://api.github.com/repos/doctrine/doctrine2/issues/4502/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/issues/4502/comments","events_url":"https://api.github.com/repos/doctrine/doctrine2/issues/4502/events","html_url":"https://github.com/doctrine/doctrine2/issues/4502","id":120671039,"number":4502,"title":"DDC-3671: Duplicated unique indexes (@UniqueConstraint annotation)","user":{"login":"doctrinebot","id":2414358,"avatar_url":"https://avatars.githubusercontent.com/u/2414358?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrinebot","html_url":"https://github.com/doctrinebot","followers_url":"https://api.github.com/users/doctrinebot/followers","following_url":"https://api.github.com/users/doctrinebot/following{/other_user}","gists_url":"https://api.github.com/users/doctrinebot/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrinebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrinebot/subscriptions","organizations_url":"https://api.github.com/users/doctrinebot/orgs","repos_url":"https://api.github.com/users/doctrinebot/repos","events_url":"https://api.github.com/users/doctrinebot/events{/privacy}","received_events_url":"https://api.github.com/users/doctrinebot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/doctrine/doctrine2/labels/Bug","name":"Bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"beberlei","id":26936,"avatar_url":"https://avatars.githubusercontent.com/u/26936?v=3","gravatar_id":"","url":"https://api.github.com/users/beberlei","html_url":"https://github.com/beberlei","followers_url":"https://api.github.com/users/beberlei/followers","following_url":"https://api.github.com/users/beberlei/following{/other_user}","gists_url":"https://api.github.com/users/beberlei/gists{/gist_id}","starred_url":"https://api.github.com/users/beberlei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beberlei/subscriptions","organizations_url":"https://api.github.com/users/beberlei/orgs","repos_url":"https://api.github.com/users/beberlei/repos","events_url":"https://api.github.com/users/beberlei/events{/privacy}","received_events_url":"https://api.github.com/users/beberlei/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-04-07T11:24:54Z","updated_at":"2015-12-11T00:35:09Z","closed_at":"2015-12-11T00:35:09Z","body":"Jira issue originally created by user webimpress:\n\nIn this commit:\nhttps://github.com/doctrine/dbal/commit/fc8beca08600b44e46f7b82998adbcc6d52c31f1\nwas changed to not checking for if index already exists. After that occur problem with duplicated unique keys (for example migrations try add unique index on the same columns with different index name).\n\nThis is an example model:\n\n```\n/****\n * @Entity\n * @Table(name=\"double*uniq_index*table\", uniqueConstraints={\n *   @UniqueConstraint(name=\"uniq_hash\", columns={\"hash\"})\n * })\n */\nclass DoubleUniqIndexModel\n{\n    /*** @Id @Column **/\n    private $id;\n\n    /*** @Column(name=\"hash\", type=\"string\", length=8, nullable=false, unique=true) **/\n    private $hash;\n}\n```\n\nand the basic test:\n\n```\n    public function testDoubleUniqIndex()\n    {\n        $em = $this->_getTestEntityManager();\n        $schemaTool = new SchemaTool($em);\n\n        $classes = array(\n            $em->getClassMetadata(*_NAMESPACE_* . '\\\\DoubleUniqIndexModel'),\n        );\n\n        $schema = $schemaTool->getSchemaFromMetadata($classes);\n\n        $this->assertTrue($schema->hasTable('double*uniq_index*table'));\n        $this->assertEquals(2, count($schema->getTable('double*uniq_index*table')->getIndexes()));\n    }\n```\n\n(I've added it into: `tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php`).\n\nTest failures, because generated schema contains three indexes (primary, and two unique on the same column with different names - one auto generated `uniq**` and one provided in annotations - `uniq*hash`)."},"comment":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/comments/163795850","html_url":"https://github.com/doctrine/doctrine2/issues/4502#issuecomment-163795850","issue_url":"https://api.github.com/repos/doctrine/doctrine2/issues/4502","id":163795850,"user":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T00:35:09Z","updated_at":"2015-12-11T00:35:09Z","body":"@zerocrates thanks, closing!"}}