mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
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.
53 lines
1.6 KiB
Go
53 lines
1.6 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 (
|
|
// Create the prod migration stream.
|
|
migStream = 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
|
|
},
|
|
}
|
|
|
|
// Create the dev migration stream.
|
|
migStreamDev = sqldb.MigrationStream{
|
|
TrackingTableName: pgx.DefaultMigrationsTable + "_dev",
|
|
SQLFileDirectory: "sqlc/migrations_dev",
|
|
SQLFiles: db.SqlSchemas,
|
|
|
|
// LatestMigrationVersion is the latest migration version of the
|
|
// dev migrations database. This is used to implement downgrade
|
|
// protection for the daemon.
|
|
//
|
|
// NOTE: This MUST be updated when a new dev migration is added.
|
|
LatestMigrationVersion: db.LatestDevMigrationVersion,
|
|
|
|
MakeProgrammaticMigrations: func(db *sqldb.BaseDB) (
|
|
map[uint]migrate.ProgrammaticMigrEntry, error) {
|
|
|
|
return make(map[uint]migrate.ProgrammaticMigrEntry), nil
|
|
},
|
|
}
|
|
LitdMigrationStreams = []sqldb.MigrationStream{migStream, migStreamDev}
|
|
)
|