|
| 1 | +//go:build dev |
| 2 | + |
| 3 | +package migrationstreams |
| 4 | + |
| 5 | +import ( |
| 6 | + "github.com/golang-migrate/migrate/v4" |
| 7 | + "github.com/golang-migrate/migrate/v4/database/pgx/v5" |
| 8 | + "github.com/lightninglabs/lightning-terminal/db" |
| 9 | + "github.com/lightningnetwork/lnd/sqldb/v2" |
| 10 | +) |
| 11 | + |
| 12 | +var ( |
| 13 | + // Create the prod migration stream. |
| 14 | + migStream = sqldb.MigrationStream{ |
| 15 | + MigrateTableName: pgx.DefaultMigrationsTable, |
| 16 | + SQLFileDirectory: "sqlc/migrations", |
| 17 | + Schemas: db.SqlSchemas, |
| 18 | + |
| 19 | + // LatestMigrationVersion is the latest migration version of the |
| 20 | + // database. This is used to implement downgrade protection for |
| 21 | + // the daemon. |
| 22 | + // |
| 23 | + // NOTE: This MUST be updated when a new migration is added. |
| 24 | + LatestMigrationVersion: db.LatestMigrationVersion, |
| 25 | + |
| 26 | + MakePostMigrationChecks: func( |
| 27 | + db *sqldb.BaseDB) (map[uint]migrate.PostStepCallback, |
| 28 | + error) { |
| 29 | + |
| 30 | + return make(map[uint]migrate.PostStepCallback), nil |
| 31 | + }, |
| 32 | + } |
| 33 | + |
| 34 | + // Create the dev migration stream. |
| 35 | + migStreamDev = sqldb.MigrationStream{ |
| 36 | + MigrateTableName: pgx.DefaultMigrationsTable + "_dev", |
| 37 | + SQLFileDirectory: "sqlc/migrations_dev", |
| 38 | + Schemas: db.SqlSchemas, |
| 39 | + |
| 40 | + // LatestMigrationVersion is the latest migration version of the |
| 41 | + // dev migrations database. This is used to implement downgrade |
| 42 | + // protection for the daemon. |
| 43 | + // |
| 44 | + // NOTE: This MUST be updated when a new dev migration is added. |
| 45 | + LatestMigrationVersion: db.LatestDevMigrationVersion, |
| 46 | + |
| 47 | + MakePostMigrationChecks: func( |
| 48 | + db *sqldb.BaseDB) (map[uint]migrate.PostStepCallback, |
| 49 | + error) { |
| 50 | + |
| 51 | + return make(map[uint]migrate.PostStepCallback), nil |
| 52 | + }, |
| 53 | + } |
| 54 | + LitdMigrationStreams = []sqldb.MigrationStream{migStream, migStreamDev} |
| 55 | +) |
0 commit comments