mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
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:
parent
9c6464f7e4
commit
f90f468a32
9 changed files with 274 additions and 17 deletions
|
|
@ -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 "+
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue