Tips

Document type migration

There might be situations in which you want to migrate content to a different document type, for example when you need a customized document type for existing content.

If you have access to the mongo shell you can use a query like this to migrate your content:

1
2
3
4
5
6
7
8
9
db.content.update(
  { "contentType": "user" }
  , 
  { $set:
    { "class": "Company\\Bundle\\ContentBundle\\Document\\Relation\\Person" }
  }
  ,
  { multi: true }
;

The first argument is the 'where' statement, this refers to the content type you want to change. The second argument is the update statement and this refers to the class of the new document type.

To get access to the mongo shell you can use SSH (Secure Shell) or install a tool like Robomongo.