Skip to content

Long upgrades through multiple calls - #53

Open
vporton wants to merge 11 commits into
NatLabs:mainfrom
vporton:feature/complex-upgrade
Open

Long upgrades through multiple calls#53
vporton wants to merge 11 commits into
NatLabs:mainfrom
vporton:feature/complex-upgrade

Conversation

@vporton

@vporton vporton commented Jul 29, 2026

Copy link
Copy Markdown

This pull request allows to do long upgrades of tables that don't fit into a single update or upgrade request.

This is an mostly AI-generated draft pull request. I didn't read it in details yet. I will definitely study it in detail, but later.

Having it importance and possible debate, I decided to release it as a draft (WIP PR) for the community to look into it asap.

I am creating a draft pull request for community consideration because the file tests/cluster-tests/Migration.Functional.Test.mo look OK, so the general idea appears correct.

@vporton

vporton commented Jul 29, 2026

Copy link
Copy Markdown
Author

Actually GPT-4.6 showed itself more creative than I did: It invented to upgrade through a separate upgrader canister, what I myself missed.

@vporton vporton left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the AI code manually and recommend the code for release.

Comment on lines +140 to +153
/// Returns documents whose ids lie in the inclusive range from `start`
/// through `end`. Either bound may be null. The underlying B-tree seeks
/// directly to `start`, so this is suitable for bounded resumable work.
public func scan(start : ?T.DocumentId, end : ?T.DocumentId) : Iter<(T.DocumentId, Record)> {
let iter = StableCollection.scan(collection, start, end);

Iter.map<(T.DocumentId, Blob), (T.DocumentId, Record)>(
iter,
func((id, candid_blob) : (T.DocumentId, Blob)) {
(id, blobify.from_blob(candid_blob));
},
);
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Comment on lines +138 to +146
public func scan(collection : T.StableCollection, start : ?T.DocumentId, end : ?T.DocumentId) : T.Iter<(T.DocumentId, Blob)> {
Iter.map<(T.DocumentId, T.CandidBlob), (T.DocumentId, Blob)>(
DocumentStore.scan(collection, start, end),
func((id, partial_candid_blob) : (T.DocumentId, T.CandidBlob)) : (T.DocumentId, Blob) {
(id, CollectionUtils.appendTypeHeaderToCandidBlob(collection, partial_candid_blob));
},
);
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Comment on lines +44 to +45
import MigrationController "Migration";
import MigrationTemplate "MigrationTemplates";

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Comment on lines +52 to +53
public let Migration = MigrationController;
public let MigrationTemplates = MigrationTemplate;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Comment thread changelog.md

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Comment thread README.md

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

@vporton
vporton marked this pull request as ready for review July 31, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant