Portal provides utilities for migrating the metadata schema between systems. This can either be accomplished by calling the appropriate management commands, or by calling the REST API endpoints from a REST client such as Curl or Postman. This functionality can for example be useful when you have a staging or testing system setup and want to move the metadata schema over to the production system.
The metadata schema can be exported using the management command:
/opt/cantemo/portal/manage.py export_metadata_schema <filename>
This will export a json representation of the metadata schema to <filename>. The filename can also be the character - which will export the schema to the terminal or another application which is useful for automation tools.
This command takes the parameter –skip-metadata-elements if you want to ignore the metadata elements setup in the source system. This can improve export and import performance if there are a lot of metadata elements.
The endpoint for exporting the metadata schema is /API/v2/metadata-schema/migrate/ and this endpoint can also be called to accomplish the same thing as the command above. Please see the REST API documentation for more information.
The dump created above can be imported into a different system using the command:
/opt/cantemo/portal/manage.py import_metadata_schema <filename>
This will recreate all metadata groups, fields and options from the source system in the target system and will make sure the schema is in sync. Any groups or fields which have been removed from a metadata group in the source system will also be removed from the target system. Please note that this can have the same effect as removing a field from a group in the Metadata Manager, causing the metadata in that field no longer to be visible in the metadata form.