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: Remove required Close from database.Migrate #25

Merged
merged 4 commits into from
Jan 14, 2022

Conversation

kylecarbs
Copy link
Member

This caused an unfortunate requirement of two database connections to instantiate a single instance. Now, the same connection can be used for migrations and querying.

@kylecarbs kylecarbs self-assigned this Jan 13, 2022
@codecov
Copy link

codecov bot commented Jan 13, 2022

Codecov Report

Merging #25 (d459b83) into main (a461bc1) will increase coverage by 0.38%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
+ Coverage   71.54%   71.93%   +0.38%     
==========================================
  Files          37       37              
  Lines        1311     1304       -7     
  Branches        7        7              
==========================================
  Hits          938      938              
+ Misses        299      294       -5     
+ Partials       74       72       -2     
Flag Coverage Δ
unittest-go-macos-latest 63.65% <0.00%> (-0.06%) ⬇️
unittest-go-ubuntu-latest 71.61% <100.00%> (+0.42%) ⬆️
unittest-go-windows-latest 63.94% <0.00%> (+0.53%) ⬆️
unittest-js 71.01% <ø> (ø)
Impacted Files Coverage Δ
database/migrate.go 28.57% <100.00%> (+3.57%) ⬆️
peer/conn.go 75.53% <0.00%> (-0.92%) ⬇️
peerbroker/dial.go 77.27% <0.00%> (+4.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a461bc1...d459b83. Read the comment docs.

Comment on lines -41 to -46
if srcErr != nil {
return xerrors.Errorf("close source: %w", err)
}
if dbErr != nil {
return xerrors.Errorf("close database: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so whoever calls Migrate needs to be responsible for cleaning up the db? May be worth noting in the comment for that function - I'd assume if I'm just passing in the dbName that this would be handled for me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove dbName as an argument actually. It's primarily used for debug logging, but isn't required at all.

Then it'll make more sense that this doesn't close the conn.

@kylecarbs kylecarbs merged commit 5c49f1f into main Jan 14, 2022
@kylecarbs kylecarbs deleted the migratewithoutclose branch January 14, 2022 16:30
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.

None yet

2 participants