-
Notifications
You must be signed in to change notification settings - Fork 266
refactor: modularize messaging persistence #6998
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
Conversation
Jenkins BuildsClick to see older builds (85)
|
0ee8ad6 to
459e2ec
Compare
459e2ec to
78d6e84
Compare
|
@igor-sirotin @dlipicar it is now ready for review 🙏 |
igor-sirotin
left a comment
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.
Didn't look the whole code yet, this is the first part of comments
sqlite/migrate.go
Outdated
| if _, err := db.Exec(createIndex); err != nil { | ||
| return err | ||
| } | ||
| insertVersion := fmt.Sprintf(`INSERT INTO %s (version, dirty) VALUES (?, ?)`, name) // nolint:gosec |
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.
How about this to avoid // nolint?
| insertVersion := fmt.Sprintf(`INSERT INTO %s (version, dirty) VALUES (?, ?)`, name) // nolint:gosec | |
| insertVersion := fmt.Sprintf(`INSERT INTO %s (version, dirty)`, name) + "VALUES (?, ?)" |
78d6e84 to
557faaa
Compare
99abe84 to
6445824
Compare
igor-sirotin
left a comment
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.
Nothing critical, just 19 little comments 😂
Great job! 👏
Would be amazing if you can write down the approach in some README in the repo. So that further we can follow it with other modules.
protocol/migrations/sqlite/1712905223_add_parity_to_message_segments.up.sql
Outdated
Show resolved
Hide resolved
| db, err := helpers.SetupTestMemorySQLDB(helpers.NewTestDBInitializer([]*bindata.AssetSource{ | ||
| { | ||
| Names: migrations.AssetNames(), | ||
| AssetFunc: migrations.Asset, | ||
| }, |
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 can implement
package migrations
func AssetSources() []*bindata.AssetSource {
return []*bindata.AssetSource{
{
Names: AssetNames(),
AssetFunc: Asset,
},
}
}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.
Agree, we see these two lines repeated in a lot of places, would be nice to make it a single one
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.
migrations is a generated package. I’d have to create a separate file for each module containing migrations and define an identical AssetSources() function, which is also far from ideal. For now, I prefer duplication for the sake of simplicity, wdyt?
messaging/waku/migrations/sqlite/1691753800_pubsubtopic_key.up.sql
Outdated
Show resolved
Hide resolved
- make each messaging submodule define its own persistence interface and SQLite implementation reference - separate migration tables for messaging submodules - move migrations from protocol to relevant messaging submodules closes: #6792
6445824 to
18059a8
Compare
SQLite implementation reference
Explanation of how to move existing migrations to submodules: https://miro.com/app/board/uXjVJ3l1qdo=/?moveToWidget=3458764645112517555&cot=14
closes: #6792