66 "database/sql"
77 "errors"
88 "fmt"
9-
10- "github.com/lightninglabs/lightning-terminal/db/sqlc"
9+ "github.com/lightninglabs/lightning-terminal/db/sqlcmig6"
1110 "github.com/lightningnetwork/lnd/fn"
1211 "github.com/lightningnetwork/lnd/sqldb"
1312 "go.etcd.io/bbolt"
@@ -80,7 +79,7 @@ type privacyPairs = map[int64]map[string]string
8079// NOTE: As sessions may contain linked sessions and accounts, the sessions and
8180// accounts sql migration MUST be run prior to this migration.
8281func MigrateFirewallDBToSQL (ctx context.Context , kvStore * bbolt.DB ,
83- sqlTx SQLQueries ) error {
82+ sqlTx * sqlcmig6. Queries ) error {
8483
8584 log .Infof ("Starting migration of the rules DB to SQL" )
8685
@@ -105,7 +104,7 @@ func MigrateFirewallDBToSQL(ctx context.Context, kvStore *bbolt.DB,
105104// database to the SQL database. The function also asserts that the
106105// migrated values match the original values in the KV store.
107106func migrateKVStoresDBToSQL (ctx context.Context , kvStore * bbolt.DB ,
108- sqlTx SQLQueries ) error {
107+ sqlTx * sqlcmig6. Queries ) error {
109108
110109 log .Infof ("Starting migration of the KV stores to SQL" )
111110
@@ -367,15 +366,15 @@ func collectKVPairs(bkt *bbolt.Bucket, errorOnBuckets, perm bool,
367366}
368367
369368// insertPair inserts a single key-value pair into the SQL database.
370- func insertPair (ctx context.Context , tx SQLQueries ,
369+ func insertPair (ctx context.Context , tx * sqlcmig6. Queries ,
371370 entry * kvEntry ) (* sqlKvEntry , error ) {
372371
373372 ruleID , err := tx .GetOrInsertRuleID (ctx , entry .ruleName )
374373 if err != nil {
375374 return nil , err
376375 }
377376
378- p := sqlc .InsertKVStoreRecordParams {
377+ p := sqlcmig6 .InsertKVStoreRecordParams {
379378 Perm : entry .perm ,
380379 RuleID : ruleID ,
381380 EntryKey : entry .key ,
@@ -427,13 +426,13 @@ func insertPair(ctx context.Context, tx SQLQueries,
427426
428427// getSQLValue retrieves the key value for the given kvEntry from the SQL
429428// database.
430- func getSQLValue (ctx context.Context , tx SQLQueries ,
429+ func getSQLValue (ctx context.Context , tx * sqlcmig6. Queries ,
431430 entry * sqlKvEntry ) ([]byte , error ) {
432431
433432 switch {
434433 case entry .featureID .Valid && entry .groupID .Valid :
435434 return tx .GetFeatureKVStoreRecord (
436- ctx , sqlc .GetFeatureKVStoreRecordParams {
435+ ctx , sqlcmig6 .GetFeatureKVStoreRecordParams {
437436 Perm : entry .perm ,
438437 RuleID : entry .ruleID ,
439438 GroupID : entry .groupID ,
@@ -443,7 +442,7 @@ func getSQLValue(ctx context.Context, tx SQLQueries,
443442 )
444443 case entry .groupID .Valid :
445444 return tx .GetGroupKVStoreRecord (
446- ctx , sqlc .GetGroupKVStoreRecordParams {
445+ ctx , sqlcmig6 .GetGroupKVStoreRecordParams {
447446 Perm : entry .perm ,
448447 RuleID : entry .ruleID ,
449448 GroupID : entry .groupID ,
@@ -452,7 +451,7 @@ func getSQLValue(ctx context.Context, tx SQLQueries,
452451 )
453452 case ! entry .featureID .Valid && ! entry .groupID .Valid :
454453 return tx .GetGlobalKVStoreRecord (
455- ctx , sqlc .GetGlobalKVStoreRecordParams {
454+ ctx , sqlcmig6 .GetGlobalKVStoreRecordParams {
456455 Perm : entry .perm ,
457456 RuleID : entry .ruleID ,
458457 Key : entry .key ,
@@ -501,7 +500,7 @@ func verifyBktKeys(bkt *bbolt.Bucket, errorOnKeyValues bool,
501500// from the KV database to the SQL database. The function also asserts that the
502501// migrated values match the original values in the privacy mapper store.
503502func migratePrivacyMapperDBToSQL (ctx context.Context , kvStore * bbolt.DB ,
504- sqlTx SQLQueries ) error {
503+ sqlTx * sqlcmig6. Queries ) error {
505504
506505 log .Infof ("Starting migration of the privacy mapper store to SQL" )
507506
@@ -536,7 +535,7 @@ func migratePrivacyMapperDBToSQL(ctx context.Context, kvStore *bbolt.DB,
536535
537536// collectPrivacyPairs collects all privacy pairs from the KV store.
538537func collectPrivacyPairs (ctx context.Context , kvStore * bbolt.DB ,
539- sqlTx SQLQueries ) (privacyPairs , error ) {
538+ sqlTx * sqlcmig6. Queries ) (privacyPairs , error ) {
540539
541540 groupPairs := make (privacyPairs )
542541
@@ -665,7 +664,7 @@ func collectPairs(pairsBucket *bbolt.Bucket) (map[string]string, error) {
665664}
666665
667666// insertPrivacyPairs inserts the collected privacy pairs into the SQL database.
668- func insertPrivacyPairs (ctx context.Context , sqlTx SQLQueries ,
667+ func insertPrivacyPairs (ctx context.Context , sqlTx * sqlcmig6. Queries ,
669668 pairs privacyPairs ) error {
670669
671670 for groupId , groupPairs := range pairs {
@@ -684,12 +683,12 @@ func insertPrivacyPairs(ctx context.Context, sqlTx SQLQueries,
684683// an error if a duplicate pair is found. The function takes a map of real
685684// to pseudo values, where the key is the real value and the value is the
686685// corresponding pseudo value.
687- func insertGroupPairs (ctx context.Context , sqlTx SQLQueries , groupID int64 ,
688- pairs map [string ]string ) error {
686+ func insertGroupPairs (ctx context.Context , sqlTx * sqlcmig6. Queries ,
687+ groupID int64 , pairs map [string ]string ) error {
689688
690689 for realVal , pseudoVal := range pairs {
691690 err := sqlTx .InsertPrivacyPair (
692- ctx , sqlc .InsertPrivacyPairParams {
691+ ctx , sqlcmig6 .InsertPrivacyPairParams {
693692 GroupID : groupID ,
694693 RealVal : realVal ,
695694 PseudoVal : pseudoVal ,
@@ -706,7 +705,7 @@ func insertGroupPairs(ctx context.Context, sqlTx SQLQueries, groupID int64,
706705
707706// validatePrivacyPairsMigration validates that the migrated privacy pairs
708707// match the original values in the KV store.
709- func validatePrivacyPairsMigration (ctx context.Context , sqlTx SQLQueries ,
708+ func validatePrivacyPairsMigration (ctx context.Context , sqlTx * sqlcmig6. Queries ,
710709 pairs privacyPairs ) error {
711710
712711 for groupId , groupPairs := range pairs {
@@ -727,12 +726,12 @@ func validatePrivacyPairsMigration(ctx context.Context, sqlTx SQLQueries,
727726// for each real value, the pseudo value in the SQL database matches the
728727// original pseudo value, and vice versa. If any mismatch is found, it returns
729728// an error indicating the mismatch.
730- func validateGroupPairsMigration (ctx context.Context , sqlTx SQLQueries ,
729+ func validateGroupPairsMigration (ctx context.Context , sqlTx * sqlcmig6. Queries ,
731730 groupID int64 , pairs map [string ]string ) error {
732731
733732 for realVal , pseudoVal := range pairs {
734733 resPseudoVal , err := sqlTx .GetPseudoForReal (
735- ctx , sqlc .GetPseudoForRealParams {
734+ ctx , sqlcmig6 .GetPseudoForRealParams {
736735 GroupID : groupID ,
737736 RealVal : realVal ,
738737 },
@@ -752,7 +751,7 @@ func validateGroupPairsMigration(ctx context.Context, sqlTx SQLQueries,
752751 }
753752
754753 resRealVal , err := sqlTx .GetRealForPseudo (
755- ctx , sqlc .GetRealForPseudoParams {
754+ ctx , sqlcmig6 .GetRealForPseudoParams {
756755 GroupID : groupID ,
757756 PseudoVal : pseudoVal ,
758757 },
0 commit comments