Every time I run doctrine:mongo:schema:update it creates the same index again. On production this takes 6 minutes, resources and probably locks the collection. It should not recreate the index again after it's initial creation.
| Q | A
|------------ | ------
| BC Break | no
| Version | 2.0.3
| MongoDB version | 4.0.14 (hosted on cloud.mongodb.com on M10 server)
When running the command, I see the following query being executed in cloud.mongodb.com

The corresponding document is this:
/**
* @ODM\Document(repositoryClass="PublicationService\Content\Repository\ContentRepository")
* @ODM\UniqueIndex(keys={"type"="asc", "identifier"="asc", "revision"="desc"})
* @ODM\Index(keys={"type"="asc", "code"="asc", "revision"="desc", "identifier"="asc"})
*/
class Content
{
use ParsableTrait;
/**
* combination of "$type|$identifier|$revision" for uniqueness and upserts.
*
* @ODM\Id(strategy="NONE")
*/
private string $id;
/**
* @ODM\Field(type="string")
*/
private string $type;
/**
* Arrangement code.
*
* Since every stream has it's own unique identifiers, every Content document is now part of a single stream.
*
* @ODM\Field(type="string")
*/
private string $code;
/**
* For now, unique id from the thedContentIdentifier.
* In the future this will be a unique publication service id from Thed.
*
* @ODM\Field(type="string")
*/
private string $identifier;
/**
* The revision number of this content.
* We use the "rev" key, hoping this is an increasing number.
*
* @ODM\Field(type="integer")
*/
private int $revision;
/**
* Content (XML string).
*
* @ODM\Field(type="string")
*/
private string $content;
/**
* @ODM\Field(type="date")
*/
private DateTimeInterface $createdAt;
This is what the index looks like when created:
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "tm-thip-prod.Content"
},
{
"v" : 2,
"unique" : true,
"key" : {
"type" : 1,
"identifier" : 1,
"revision" : -1
},
"name" : "type_1_identifier_1_revision_-1",
"sparse" : false,
"background" : false,
"ns" : "tm-thip-prod.Content"
},
{
"v" : 2,
"key" : {
"type" : 1,
"code" : 1,
"revision" : -1,
"identifier" : 1
},
"name" : "type_1_code_1_revision_-1_identifier_1",
"sparse" : false,
"background" : false,
"ns" : "tm-thip-prod.Content"
}
]
It happens every time I run doctrine:mongo:schema:update
I expect the second time that I run doctrine:mongo:schema:update that nothing happends.
Not sure if this matters, but saw this in the additional config on cloud mongo

But the size seems ok

Fixed in #2148.
Most helpful comment
Fixed in #2148.