multi: add dev kvdb to sql code migration

Add the necessary code to trigger the kvdb to sql code migration in dev
builds.
This commit is contained in:
Viktor Torstensson 2025-07-24 02:43:17 +02:00
parent 9c6464f7e4
commit f90f468a32
No known key found for this signature in database
GPG key ID: 961CC8259AE675D4
9 changed files with 274 additions and 17 deletions

View file

@ -3,6 +3,7 @@
package terminal
import (
"context"
"fmt"
"path/filepath"
@ -13,6 +14,7 @@ import (
"github.com/lightninglabs/lightning-terminal/firewalldb"
"github.com/lightninglabs/lightning-terminal/session"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/sqldb/v2"
)
@ -87,7 +89,9 @@ func defaultDevConfig() *DevConfig {
}
// NewStores creates a new stores instance based on the chosen database backend.
func NewStores(cfg *Config, clock clock.Clock) (*stores, error) {
func NewStores(ctx context.Context, cfg *Config,
basicClient lnrpc.LightningClient, clock clock.Clock) (*stores, error) {
var (
networkDir = filepath.Join(cfg.LitDir, cfg.Network)
stores = &stores{
@ -114,7 +118,11 @@ func NewStores(cfg *Config, clock clock.Clock) (*stores, error) {
if !cfg.Sqlite.SkipMigrations {
err = sqldb.ApplyAllMigrations(
sqlStore, migstreams.LitdMigrationStreams,
sqlStore,
migstreams.MakeMigrationStreams(
ctx, basicClient, cfg.MacaroonPath,
clock,
),
)
if err != nil {
return stores, fmt.Errorf("error applying "+
@ -156,7 +164,11 @@ func NewStores(cfg *Config, clock clock.Clock) (*stores, error) {
if !cfg.Postgres.SkipMigrations {
err = sqldb.ApplyAllMigrations(
sqlStore, migstreams.LitdMigrationStreams,
sqlStore,
migstreams.MakeMigrationStreams(
ctx, basicClient, cfg.MacaroonPath,
clock,
),
)
if err != nil {
return stores, fmt.Errorf("error applying "+