Merge pull request #1309 from ViktorT-11/2026-05-add-master-additions-to-migration-code

[sql-72] Add `master` additions to migration code
This commit is contained in:
Elle 2026-05-19 17:28:45 -07:00 committed by GitHub
commit 4af5788819
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 4 deletions

View file

@ -358,16 +358,24 @@ func getBBoltIndices(db kvdb.Backend) (uint64, uint64, error) {
return ErrAccountBucketNotFound
}
addValue = bucket.Get(lastAddIndexKey)
if len(addValue) == 0 {
av := bucket.Get(lastAddIndexKey)
if len(av) == 0 {
return ErrNoInvoiceIndexKnown
}
settleValue = bucket.Get(lastSettleIndexKey)
if len(settleValue) == 0 {
sv := bucket.Get(lastSettleIndexKey)
if len(sv) == 0 {
return ErrNoInvoiceIndexKnown
}
// Copy values since bbolt's Get returns slices into the
// mmap'd file, only valid within the transaction.
addValue = make([]byte, len(av))
copy(addValue, av)
settleValue = make([]byte, len(sv))
copy(settleValue, sv)
return nil
}, func() {
addValue, settleValue = nil, nil

View file

@ -427,6 +427,25 @@ func (q *Queries) UpdateAccountExpiry(ctx context.Context, arg UpdateAccountExpi
return id, err
}
const updateAccountLabel = `-- name: UpdateAccountLabel :one
UPDATE accounts
SET label = $1
WHERE id = $2
RETURNING id
`
type UpdateAccountLabelParams struct {
Label sql.NullString
ID int64
}
func (q *Queries) UpdateAccountLabel(ctx context.Context, arg UpdateAccountLabelParams) (int64, error) {
row := q.db.QueryRowContext(ctx, updateAccountLabel, arg.Label, arg.ID)
var id int64
err := row.Scan(&id)
return id, err
}
const updateAccountLastUpdate = `-- name: UpdateAccountLastUpdate :one
UPDATE accounts
SET last_updated = $1

View file

@ -70,6 +70,7 @@ type Querier interface {
UpdateAccountAliasForTests(ctx context.Context, arg UpdateAccountAliasForTestsParams) (int64, error)
UpdateAccountBalance(ctx context.Context, arg UpdateAccountBalanceParams) (int64, error)
UpdateAccountExpiry(ctx context.Context, arg UpdateAccountExpiryParams) (int64, error)
UpdateAccountLabel(ctx context.Context, arg UpdateAccountLabelParams) (int64, error)
UpdateAccountLastUpdate(ctx context.Context, arg UpdateAccountLastUpdateParams) (int64, error)
UpdateFeatureKVStoreRecord(ctx context.Context, arg UpdateFeatureKVStoreRecordParams) error
UpdateGlobalKVStoreRecord(ctx context.Context, arg UpdateGlobalKVStoreRecordParams) error