cmd/tools/migrate-segment-copies: fix placement scan from DB

Placement can be null in DB and we need adjust scanning this column
from DB.

Additionally this change sets application name for DB connection.

Change-Id: I3c7d6294f4a3e5e441160b2fd4aeafffe705ec76
This commit is contained in:
Michal Niewrzal 2023-07-21 15:07:23 +02:00 committed by Michał Niewrzał
parent 6e4044b245
commit d9525a0f27

View File

@ -81,7 +81,9 @@ func main() {
func Migrate(ctx context.Context, log *zap.Logger, config Config) (err error) {
defer mon.Task()(&ctx)(&err)
db, err := metabase.Open(ctx, log, config.MetabaseDB, metabase.Config{})
db, err := metabase.Open(ctx, log, config.MetabaseDB, metabase.Config{
ApplicationName: "migrate-segment-copies",
})
if err != nil {
return errs.New("unable to connect %q: %w", config.MetabaseDB, err)
}
@ -164,7 +166,7 @@ func MigrateSegments(ctx context.Context, log *zap.Logger, metabaseDB *metabase.
RemoteAliasPieces []byte
RootPieceID []byte
RepairedAt *time.Time
Placement int64
Placement *int64
}
updates := []Update{}
@ -176,7 +178,7 @@ func MigrateSegments(ctx context.Context, log *zap.Logger, metabaseDB *metabase.
var position int64
var remoteAliasPieces, rootPieceID []byte
var repairedAt *time.Time
var placement int64
var placement *int64
err := rows.Scan(&ancestorStreamID, &position, &remoteAliasPieces, &rootPieceID, &repairedAt, &placement)
if err != nil {
return err