H5P Guides

Content upgrade

New minor or major versions of a library may introduce new content structures and provide an upgrade script that upgrades existing content created for the previous versions of the library to the new content structure. 

Upgrade scripts

Upgrade scripts must be included in the first patch version for the new minor or major version, i.e. patch version 0. Upgrade scripts may not be introduced in a new patch version for an existing major and minor version of a library.

The upgrade script is placed in the library root folder in a file named upgrades.js

The script must extend the global H5PUpgrades object and add a function in this object where the name of the function is the library machine name.

The function must return an object with the following structure:

  [majorVersion]: {
    [minorVersion]: {
      contentUpgrade: function (parameters, finished) {}

The parameters object contains the json content for the library. Finished is a callback function that will be called when the upgrade is done. The first parameter is an optional error, which should be null if nothing goes wrong. The second is the changed parameters.

A new minor or major version of a library must not remove existing contentUpgrade functions from the upgrades.js file, only add new.


var H5PUpgrades = H5PUpgrades || {};

H5PUpgrades['H5P.Summary'] = (function ($) {
  return {
    1: {
      1: function (parameters, finished) {
        // Wrap summaries to allow tip.
        for (var i = 0; i < parameters.summaries.length; i++) {
          parameters.summaries[i] = {
            summary: parameters.summaries[i]

        finished(null, parameters);