Upgrades a Data Package, its Data Resources and Table Schemas to the v2 specification.
Arguments
- package
Data Package object, as returned by
read_package()orcreate_package().
Upgrade details
Data Package
upgrade_package() upgrades a v1 descriptor to v2 as follows:
Adds
$schemaas first property and sets it to the recommended v2 value ("https://datapackage.org/profiles/2.0/datapackage.json"), except for certainprofilevalues.Removes
profile, but retains its value in$schemaif it is a URL to a custom profile (see backwards compatibility).Converts
contributors"role": "value"to"roles": ["value"](see changelog).
Data Resource
upgrade_package() upgrades any v1 resource to v2 as follows:
Adds
$schemaas first property and sets it to the recommended v2 value ("https://datapackage.org/profiles/2.0/dataresource.json").Removes
profile, but converts"profile" = "tabular-data-resource"to"type" = "table"(see backwards compatibility).
Table Schema
upgrade_package() upgrades any verbose v1 schema to v2 as follows:
Adds
$schemaas first property and sets it to the recommended v2 value ("https://datapackage.org/profiles/2.0/tableschema.json").Converts
primaryKeysingle values to an array (see changelog).Converts
foreignKeyssingle values infieldsto an array and removesreference$resourceif it is self-referential (see changelog).
Schemas referenced by path or URL are left as is.
See also
Other versioning functions:
version()
Examples
# Load the v1 example Data Package
(package <- example_package(version = "1.0"))
#> A Data Package (version 1.0) with 3 resources:
#> • deployments
#> • observations
#> • media
#> Use `unclass()` to print the Data Package as a list.
# Upgrade
(package_upgraded <- upgrade_package(package))
#> A Data Package (version 2.0) with 3 resources:
#> • deployments
#> • observations
#> • media
#> Use `unclass()` to print the Data Package as a list.
# Check version of one of the resources
version(resource(package_upgraded, "deployments"))
#> [1] "2.0"
