mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopdb: add ability to track manual migrations
This commit is contained in:
parent
4f5c806ba5
commit
c650cdc8a8
11 changed files with 151 additions and 0 deletions
|
|
@ -439,6 +439,29 @@ func (b *BaseDB) BatchUpdateLoopOutSwapCosts(ctx context.Context,
|
|||
})
|
||||
}
|
||||
|
||||
// HasMigration returns true if the migration with the given ID has been done.
|
||||
func (b *BaseDB) HasMigration(ctx context.Context, migrationID string) (
|
||||
bool, error) {
|
||||
|
||||
migration, err := b.GetMigration(ctx, migrationID)
|
||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return migration.MigrationTs.Valid, nil
|
||||
}
|
||||
|
||||
// SetMigration marks the migration with the given ID as done.
|
||||
func (b *BaseDB) SetMigration(ctx context.Context, migrationID string) error {
|
||||
return b.InsertMigration(ctx, sqlc.InsertMigrationParams{
|
||||
MigrationID: migrationID,
|
||||
MigrationTs: sql.NullTime{
|
||||
Time: time.Now().UTC(),
|
||||
Valid: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// loopToInsertArgs converts a SwapContract struct to the arguments needed to
|
||||
// insert it into the database.
|
||||
func loopToInsertArgs(hash lntypes.Hash,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue