Upgrading a doc to a different schema?

Let’s say I have two schemas. I want to convert my document from the older schema to the newer schema. Does ProseMirror have any built in functions to do this? Or do I have to write my own?

Let’s say schema_v1 is doc: { content: “heading paragraph”} and schema_v2 is doc: { content: “heading paragraph horizontal_rule paragraph” }. My document was created with schema_v1 but now I’m trying to open it and edit it with a schema_v2 Editor. What I want is for the Editor Model/View to see that my doc is missing a horizontal_rule and paragraph and to over to add the missing documents to the Doc JSON for me.

Otherwise my plan is to write a function comparing the new schema I want to open the doc with to the Doc that was saved with the older schema. That function will recursively compare what it finds in the schema to what it finds in the Doc. If a Node element is missing, it will add an empty version of that Node as a placeholder. That way when I open the Doc in the editor with the new schema, the User will see the missing Nodes.

No. You’ll need to write your own code to convert documents.

Thank you for the quick reply!