mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
db: add LitdMigrationStream
A core component of `sqldb/v2` useage, is that the package allows and requires that the callsite defines a `sqldb.MigrationStream` that will be run during the initialization of the `sqldb/v2 database instance. The `sqldb.MigrationStream` defines the exact sql migrations to run, as well as additional code migrations will be run after each individual migration version. This commit introduces the core definition of the migration stream for `litd`, and will be further exteded in upcoming commits that will introduce kvdb to sql code migration. Note that as of this commit, as no part of the `litd` codebase uses the `sqldb/v2` database instances, this migration stream is not yet used.
This commit is contained in:
parent
1f9c32df93
commit
ee4a1e338b
1 changed files with 31 additions and 0 deletions
31
db/sql_migrations.go
Normal file
31
db/sql_migrations.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
"github.com/golang-migrate/migrate/v4/database/pgx/v5"
|
||||
"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: 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: LatestMigrationVersion,
|
||||
|
||||
MakeProgrammaticMigrations: func(db *sqldb.BaseDB) (
|
||||
map[uint]migrate.ProgrammaticMigrEntry, error) {
|
||||
|
||||
return make(map[uint]migrate.ProgrammaticMigrEntry), nil
|
||||
},
|
||||
}
|
||||
LitdMigrationStreams = []sqldb.MigrationStream{LitdMigrationStream}
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue