-
Notifications
You must be signed in to change notification settings - Fork 2
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
NOISSUE - Add Things Migration #2
base: main
Are you sure you want to change the base?
Conversation
cmd/migrate/main.go
Outdated
@@ -0,0 +1,39 @@ | |||
package main |
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.
No need for a migrate
subdirectory, cmd/main.go
is just fine.
migrate/migrate.go
Outdated
func connectToThingsDB(dbConfig mf13thingspostgres.Config) *sqlx.DB { | ||
db, err := mf13thingspostgres.Connect(dbConfig) | ||
if err != nil { | ||
log.Panic(fmt.Errorf("Failed to connect to things postgres: %s", err)) |
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.
Use log.Fatalf
instead.
cmd/migrate/main.go
Outdated
// Root Flags | ||
rootCmd.PersistentFlags().StringVarP(&cfg.FromVersion, "fromversion", "f", "0.13.0", "mainflux version you want to migrate from") | ||
rootCmd.PersistentFlags().StringVarP(&cfg.ToVersion, "toversion", "t", "0.14.0", "mainflux version you want to migrate to") | ||
rootCmd.PersistentFlags().StringVarP(&cfg.Operation, "operation", "o", "export", "export dataor import data to a new mainflux deployment") |
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.
Fix typo.
migrate/users/minisdk.go
Outdated
} | ||
o := limit | ||
limit = util.UpdateLimit(usersPage.Total) | ||
for o < usersPage.Total { |
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.
The idea of fetching everything from the DB to the RAM. That's the point of pagination. This should be more like a pipe where we stream (channel) the batch, and publish it to the next phase to process. Bear in mind that we'll need to remember "last saved" so in case something goes wrong we don't need to start over.
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo <[email protected]>
1c3819f
to
809adf8
Compare
Signed-off-by: rodneyosodo <[email protected]>
cmd/main.go
Outdated
) | ||
|
||
const ( | ||
migrationDuration = 1 * time.Hour |
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.
this might not be a good idea to set a fixed value because we don't know how long it could take for different sizes of migrations
internal/query.go
Outdated
switch { | ||
case total <= limit1000: | ||
return defLimit | ||
case total <= limit10000: | ||
return limit1000 | ||
case total <= limit100000: | ||
return limit10000 | ||
case total <= limit1000000: |
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.
this can be reduced a mathematical statement
migrate/migrate.go
Outdated
|
||
func Migrate(ctx context.Context, cfg migrations.Config, logger logger.Logger) { | ||
go func() { | ||
log.Println(http.ListenAndServe("localhost:6060", nil)) |
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.
use mainflux logger
regarding the token timeout, you can add to documentation on how to change env var to create a longer duration token for migration purposes |
Signed-off-by: rodneyosodo <[email protected]>
Signed-off-by: rodneyosodo [email protected]
KNOWN ISSUES