Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scan error when fetching archived contracts #1585

Open
wants to merge 4 commits into
base: api-breakers
Choose a base branch
from

Conversation

peterjan
Copy link
Member

@peterjan peterjan commented Sep 27, 2024

This PR fixes a scan error when fetching contracts using the new filter mode api.ContractFilterModeArchived.

Related #1545

@peterjan peterjan self-assigned this Sep 27, 2024
@peterjan peterjan marked this pull request as ready for review October 7, 2024 10:39
@@ -12,7 +12,7 @@ type Scanner interface {

type ContractRow struct {
FCID FileContractID
HostID int64
HostID *int64
Copy link
Member

Choose a reason for hiding this comment

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

Will a contract ever not be attached to a host where nil would make sense?

Copy link
Member Author

@peterjan peterjan Oct 15, 2024

Choose a reason for hiding this comment

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

Yes, we merged contracts and archived_contracts into a single contracts table. If a host we used before goes offline for an extended period of time we remove it (RemoveOfflineHosts), so it's possible for a row in the contracts table to point to a host that no longer exists.

Edit: sorry, bit too fast on the trigger, we nullify the host_id when we archive a contract, we do that so we can remove offline hosts without breaking the FK check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants