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

Add database migrations #224

Merged
merged 6 commits into from
Nov 8, 2022
Merged

Add database migrations #224

merged 6 commits into from
Nov 8, 2022

Conversation

avalonche
Copy link
Collaborator

πŸ“ Summary

Adding database migrations as go files for dynamic table names. Tested with local docker Postgres db.

β›± Motivation and Context

Resolves Issue #203

πŸ“š References

To run:

./boost-relay tool migrate

which automates the migration process. It is placed under the tool command for now but happy to move it out to a new command e.g. ./boost-relay migrate.


βœ… I have run these commands

  • make lint
  • make test-race
  • go mod tidy
  • I have seen and agree to CONTRIBUTING.md

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2022

Codecov Report

Merging #224 (5d8ed25) into main (23ea413) will increase coverage by 0.05%.
The diff coverage is 19.32%.

@@            Coverage Diff             @@
##             main     #224      +/-   ##
==========================================
+ Coverage   23.91%   23.97%   +0.05%     
==========================================
  Files          19       19              
  Lines        2383     2440      +57     
==========================================
+ Hits          570      585      +15     
- Misses       1732     1774      +42     
  Partials       81       81              
Flag Coverage Ξ”
unittests 23.97% <19.32%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Ξ”
common/types.go 0.00% <0.00%> (ΓΈ)
database/mockdb.go 0.00% <0.00%> (ΓΈ)
database/database.go 13.55% <27.05%> (+3.43%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@metachris
Copy link
Collaborator

That's great!

Should this PR also remove database/schema.go?

@avalonche
Copy link
Collaborator Author

there's still some code in database relying on schema.go. I have replaced with migrations on startup.

@metachris
Copy link
Collaborator

the table where the migration status is saved also needs the prefix! currently it's saving into "gorp_migrations", but should be "PREFIX_migrations"

migrate "github.com/rubenv/sql-migrate"
)

func GetInitDatabase() *migrate.Migration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have a function here at all, instead of just var Migration001InitDatabase = migrate.Migration{...?

@metachris
Copy link
Collaborator

thank you very much!

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.

3 participants