I have a collection that looks like this:
{
"_id": "5c90e8736441c96cc8e5c703",
"meta": {
"schemaVersion": 1,
"locHint": {
"region": "150",
"country": "GBR"
}
},
"name": "My test study"
}
And the following validator:
{
"$jsonSchema": {
"bsonType": "object",
"required": [
"meta.schemaVersion"
"meta.locHint.region",
"meta.locHint.country",
"name"
],
"properties": {
"meta.schemaVersion": {
"bsonType": "int",
"description": "Version counter used schema changes"
},
"meta.locHint.region": {
"bsonType": "string",
"pattern": "^[0-9]{3}$",
"description": "meta.locHint.region is required to be a valid iso3166 region (3 digits)"
},
"meta.locHint.country": {
"bsonType": "string",
"pattern": "^[A-Z]{3}$",
"description": "meta.locHint.country is required to be a valid iso3166 alpha-3 (3 upper case letters)"
},
"name": {
"bsonType": "string",
"description": "name is required and must be a string"
}
}
}
}
What do I want to achieve is: rename (update) region to m46Region, country to iso3166Country and change the pattern for meta.locHint.country using a MongoBee migration script.
When I try to do that, mongo says that my document is not valid and it's not allowing me to rename the fields.
How do I update the validators as well? or remove and recreate them?