migstreams: introduce migstreams package

The upcoming kvdb to sql code migration will be added to as part of the
`sqldb/v2` migration stream. However, since the kvdb to sql migration
will need to use the migration functions present in the `accounts`,
`firewalldb`, and `session` packages, the migration will need to
referernce those packages. That would lead to a circular dependency
though if the migration stream was defined in the `db` package, as those
packages need to import the `db` package.

To avoid this, we introduce a new `migstreams` package that
contains the migration streams, and ensure that the `db` package doesn't
import the `migstreams` package.
This commit is contained in:
Viktor Torstensson 2025-07-11 20:05:45 +02:00
parent f77ae5dcf2
commit 83f3e223fb
No known key found for this signature in database
GPG key ID: 961CC8259AE675D4
5 changed files with 40 additions and 5 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/lightninglabs/lightning-terminal/accounts"
"github.com/lightninglabs/lightning-terminal/db"
"github.com/lightninglabs/lightning-terminal/db/migstreams"
"github.com/lightninglabs/lightning-terminal/db/sqlc"
"github.com/lightninglabs/lightning-terminal/firewalldb"
"github.com/lightninglabs/lightning-terminal/session"
@ -113,7 +114,7 @@ func NewStores(cfg *Config, clock clock.Clock) (*stores, error) {
if !cfg.Sqlite.SkipMigrations {
err = sqldb.ApplyAllMigrations(
sqlStore, db.LitdMigrationStreams,
sqlStore, migstreams.LitdMigrationStreams,
)
if err != nil {
return stores, fmt.Errorf("error applying "+
@ -155,7 +156,7 @@ func NewStores(cfg *Config, clock clock.Clock) (*stores, error) {
if !cfg.Postgres.SkipMigrations {
err = sqldb.ApplyAllMigrations(
sqlStore, db.LitdMigrationStreams,
sqlStore, migstreams.LitdMigrationStreams,
)
if err != nil {
return stores, fmt.Errorf("error applying "+