{"action":"reopened","issue":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1135","labels_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1135/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1135/comments","events_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1135/events","html_url":"https://github.com/doctrine/mongodb-odm/issues/1135","id":87179061,"number":1135,"title":"Indexes not created when embedding a document using mixed document types ","user":{"login":"bicatu","id":227536,"avatar_url":"https://avatars.githubusercontent.com/u/227536?v=3","gravatar_id":"","url":"https://api.github.com/users/bicatu","html_url":"https://github.com/bicatu","followers_url":"https://api.github.com/users/bicatu/followers","following_url":"https://api.github.com/users/bicatu/following{/other_user}","gists_url":"https://api.github.com/users/bicatu/gists{/gist_id}","starred_url":"https://api.github.com/users/bicatu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bicatu/subscriptions","organizations_url":"https://api.github.com/users/bicatu/orgs","repos_url":"https://api.github.com/users/bicatu/repos","events_url":"https://api.github.com/users/bicatu/events{/privacy}","received_events_url":"https://api.github.com/users/bicatu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/doctrine/mongodb-odm/labels/question","name":"question","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-11T02:14:02Z","updated_at":"2015-06-11T10:52:19Z","closed_at":null,"body":"According to the user manual when I specify the indexes on a embedded document it will be created when persisting the main document.\r\n\r\nIt is not happening when the embedded document type varies.\r\n\r\nTo reproduce\r\nMain Document Entity\r\n\r\n```php\r\n/**\r\n * @ODM\\Document\r\n */\r\nclass Document\r\n{\r\n    /**\r\n     * @var string Id\r\n     * @ODM\\Id\r\n     */\r\n    private $id;\r\n\r\n    /**\r\n     * @ODM\\EmbedOne(discriminatorField=\"type\")\r\n     */\r\n    private $embedded;\r\n\r\n    // setters and getters\r\n}\r\n```\r\n\r\nFirst embedded type\r\n```php\r\n/**\r\n * @ODM\\EmbeddedDocument\r\n */\r\nclass Embedded1\r\n{\r\n    /**\r\n     * @ODM\\Date\r\n     * @ODM\\Index\r\n     */\r\n    private $timestamp;\r\n\r\n    // setters and getters\r\n}\r\n```\r\n\r\ntest code\r\n```php\r\n$document = new Document();\r\n$embedded = new Embedded1();\r\n$embedded->setTimestamp(new \\DateTime());\r\n$document->setEmbedded($embedded);\r\n\r\n$dm->persist($document);\r\n$dm->flush();\r\n$sm = $dm->getSchemaManager();\r\n$sm->ensureIndexes();\r\n```\r\n\r\nWhen using find the document and the embedded data has been saved but the getIndexes does not show anything other than the _id.\r\n\r\nIf I update the annotation to mention targetDocument the index gets created normally."}}