"revertCodePackage" (JSON Action)
Revert the code package to the specified historical version
The "revertCodePackage" action provides a fast way to revert back to a known good version when new code is not working well.
When you revert a code package to a previous version, the server copies the current version and puts it into version history as is. It then takes the requested version of code from version history, increments the version, replaces the current code with the code from version history, and starts executing the new code.
Links: Concepts | Tutorials | FAQs
Request example
{
"api": "admin",
"action": "revertCodePackage",
"params": {
"databaseName": "faircom",
"ownerName": "admin",
"codeName": "convertTemperature",
"codeVersion": 13
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}{
"debugInfo": {
"request": {
"api": "admin",
"action": "revertCodePackage",
"params": {
"databaseName": "faircom",
"ownerName": "admin",
"codeName": "convertTemperature",
"codeVersion": 1
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}The "revertCodePackage" action reverts the code package to the specified historical version. When you revert, the server saves the current version to history, retrieves the requested historical version, increments its version number, and then replaces the current code with the historical code, after which the new (restored) code starts executing.
"params" property summariesProperty | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
specifies the name of the code package. | Required - No default value | string | 1 to 64 bytes | |
specifies the code's version stored in the version history. | Required - No default value | integer |
| |
(optional) specifies the name of the database. | Defaults to the session's | string | 1 to 64 bytes | |
(optional) specifies the name of the owner. | Defaults to the session's | string | 1 to 64 bytes |
The "codeName" property is a required, case-sensitive string between 1 and 64 bytes containing the user-defined name for the code package.
It is an error to set "codeName" to the empty string "".
The package's unique identifier is the combination of "databaseName", "ownerName", and "codeName". See the "databaseName" and "ownerName" properties for more information.
"codeVersion" is a required integer value that specifies the code's version stored in the version history.
The "databaseName" property is an optional string from 1 to 64 bytes that specifies the database that contains an object, such as a table or code package. If it is set to null or is omitted, it defaults to the default database of the JSON Action session, see "createSession" and the "defaultDatabaseName" property.
You specify this property when you want to use a different database instead of the default. Your session's account must have the appropriate privileges to access the code package.
This property is useful because objects, such as tables and code packages, can have the same name in multiple databases. This feature allows you to create multiple environments in the same server and reuse the same JSON actions in each environment. For example, you can create "dev", "test", "stage", and "prod" databases on the same server and use the "defaultDatabaseName" or "databaseName" properties to specify the desired environment.
It is an error to set "databaseName" to the empty string "".
If no default database is specified during "createSession", the server sets the "defaultDatabaseName" to the "defaultDatabaseName" value specified in the services.json file.
The "ownerName" property is an optional string from 1 to 64 bytes that specifies the account that owns an object, such as a table or code package. If it is set to null or is omitted, it defaults to the account that created the JSON Action session, see "createSession" and the "defaultOwnerName" property.
You specify this property when you want to use a different account instead of the default. Your session's account must have the appropriate privileges to access the code package.
This property is useful because objects, such as tables and code packages, can have the same name in the same database as long as different accounts own each object. This feature allows you to create duplicate objects for different users on the same server and reuse the same JSON actions on those objects. For example, an administrator can copy objects from a production environment to her account so she can troubleshoot an issue using the same JSON actions, JavaScript, and SQL code.
It is an error to set "ownerName" to the empty string "".
If no default owner is specified during "createSession", the server sets the "defaultOwnerName" to the "defaultOwnerName" value specified in the services.json file.