-
Notifications
You must be signed in to change notification settings - Fork 541
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
feat: db migration #1458
feat: db migration #1458
Conversation
c6a0a13
to
58f8750
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
"gorm.io/gorm" | ||
) | ||
|
||
type Script interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script
is too general, how about MigrationScript
migration/interface.go
Outdated
type Script interface { | ||
Up(ctx context.Context, db *gorm.DB) error | ||
Version() uint64 | ||
Owner() string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we agree that owner
is not needed.
migration/migrator.go
Outdated
m.db = db | ||
} | ||
|
||
func (m *migrator) register(scripts ...Script) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should pass one more field like comment
to declare which plugin they belong to.
and save it into database, to help with debugging
Summary
It provides a tool to keep model definitions and the database schema in sync. All the changes in the schema will be written in the database
Key Points
Description
Describe what this PR does, and aims to solve in a few sentences.
Does this close any open issues?
#1057 #1414 #1304
Current Behavior
Describe the current behaviour of this issue, if relevant.
New Behavior
Describe the new behaviour updated in this issue, if relevant.
Screenshots
Include any relevant screenshots here.
Other Information
Any other information that is important to this PR.