lightning-terminal/db/migstreams/sql_migrations.go
Viktor Torstensson 0c6b3c0539
multi: introduce dev migrations
When the kvdb to sql migration is initially introduced, we will want to
ensure that it is only run under dev builds during the testing phase.

We therefore introduce the functionality to have separate dev
migrations, which are only included in a separate migration stream that
is used only in dev builds.

Note that these dev migrations are currently not included in the
`sqlc.yaml` file, to ensure that the main sqlc models doesn't include
the dev migrations.
2026-05-14 11:38:30 +02:00

34 lines
1 KiB
Go

//go:build !dev
package migstreams
import (
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database/pgx/v5"
"github.com/lightninglabs/lightning-terminal/db"
"github.com/lightningnetwork/lnd/sqldb/v2"
)
var (
// LitdMigrationStream defines the SQL migration stream used to create
// and upgrade LiT's SQL schema.
LitdMigrationStream = sqldb.MigrationStream{
TrackingTableName: pgx.DefaultMigrationsTable,
SQLFileDirectory: "sqlc/migrations",
SQLFiles: db.SqlSchemas,
// LatestMigrationVersion is the latest migration version of the
// database. This is used to implement downgrade protection for
// the daemon.
//
// NOTE: This MUST be updated when a new migration is added.
LatestMigrationVersion: db.LatestMigrationVersion,
MakeProgrammaticMigrations: func(db *sqldb.BaseDB) (
map[uint]migrate.ProgrammaticMigrEntry, error) {
return make(map[uint]migrate.ProgrammaticMigrEntry), nil
},
}
LitdMigrationStreams = []sqldb.MigrationStream{LitdMigrationStream}
)