WEBVTT

00:00:00.500 --> 00:00:02.518
This Shop is installed and in use.

00:00:03.418 --> 00:00:07.038
Branch ten holds item twenty with five left in stock, and the

00:00:07.051 --> 00:00:08.835
tax is seven hundred and fifty.

00:00:09.733 --> 00:00:12.676
We want to release new code without losing any of that.

00:00:13.575 --> 00:00:15.697
Sort the files into two groups.

00:00:16.595 --> 00:00:20.436
Endpoints, services and checks are business code, and you may

00:00:20.450 --> 00:00:21.869
change them in any release.

00:00:22.767 --> 00:00:25.749
The versioned memory files are the saved-data contract.

00:00:26.647 --> 00:00:29.994
Once a version has shipped, leave its file exactly as it is.

00:00:30.892 --> 00:00:34.173
The upgrade checks that the new build expects the same contract

00:00:34.187 --> 00:00:35.332
the canister saved.

00:00:37.467 --> 00:00:39.680
Build the release with the SDK's builder.

00:00:40.581 --> 00:00:43.849
It produces the prepared Wasm to deploy, along with the client

00:00:43.862 --> 00:00:45.073
interface files.

00:00:45.971 --> 00:00:49.265
Deploy that prepared file and never the raw Cargo output.

00:00:50.164 --> 00:00:53.823
Use the same compiler setup, target and build options as the

00:00:53.836 --> 00:00:54.930
build that is running.

00:00:55.828 --> 00:00:58.224
Before upgrading, let work finish.

00:00:59.122 --> 00:01:02.130
A call that is still waiting on another canister must come back

00:01:02.143 --> 00:01:02.677
first.

00:01:03.575 --> 00:01:08.224
The SDK refuses an upgrade while its own calls, tasks or timers

00:01:08.237 --> 00:01:09.305
are outstanding.

00:01:10.203 --> 00:01:13.081
An app with longer jobs adds its own readiness check, which

00:01:13.094 --> 00:01:14.630
we will see in the last lesson.

00:01:15.529 --> 00:01:18.745
The upgrade request sets Wasm memory persistence to keep.

00:01:19.643 --> 00:01:22.625
The Shop test uses the same build on both sides.

00:01:23.523 --> 00:01:27.104
Its restore callback opens the saved data and binds the services

00:01:27.117 --> 00:01:28.810
again, as in lesson two.

00:01:29.708 --> 00:01:31.779
The saved values are still available.

00:01:32.677 --> 00:01:35.555
The check reads everything back through the public methods.

00:01:36.453 --> 00:01:37.755
Branch ten is there.

00:01:38.654 --> 00:01:40.581
The tax is seven hundred and fifty.

00:01:41.479 --> 00:01:44.995
Item twenty still costs one hundred and twenty-five with five

00:01:45.008 --> 00:01:45.594
in stock.

00:01:46.492 --> 00:01:50.190
And the app still works, because closing the branch succeeds.

00:01:52.333 --> 00:01:55.692
What if a release changes the saved-data contract by accident?

00:01:56.592 --> 00:01:59.783
This test tries two builds with incompatible contracts.

00:02:00.681 --> 00:02:02.530
Each upgrade is refused.

00:02:03.428 --> 00:02:06.736
The test calls the canister again, and the old program still

00:02:06.749 --> 00:02:08.350
answers with the old values.

00:02:09.249 --> 00:02:12.751
So an ordinary upgrade changes code and keeps the contract.

00:02:13.650 --> 00:02:17.139
When the saved data itself has to change, you add a new version

00:02:17.152 --> 00:02:19.574
next to the old one and say how to convert.

00:02:20.473 --> 00:02:21.762
That is the next lesson.

