Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMigrationNonUniqueName = errors.New("please provide unique migration name") ErrMigrationCommitNotCalled = errors.New("migration before-commit function was not called") ErrMigrationETLFilesDeleted = errors.New( "db migration progress was interrupted after extraction step and ETL files was deleted, please contact development team for help or re-sync from scratch", ) )
View Source
var ClearBorTables = Migration{ Name: "clear_bor_tables", Up: func(db kv.RwDB, dirs datadir.Dirs, progress []byte, BeforeCommit Callback, logger log.Logger) (err error) { tx, err := db.BeginRw(context.Background()) if err != nil { return err } defer tx.Rollback() if err := BeforeCommit(tx, nil, true); err != nil { return err } if err := reset2.ResetBorHeimdall(context.Background(), tx); err != nil { return err } return tx.Commit() }, }
View Source
var ProhibitNewDownloadsLock = Migration{ Name: "prohibit_new_downloads_lock", Up: func(db kv.RwDB, dirs datadir.Dirs, progress []byte, BeforeCommit Callback, logger log.Logger) (err error) { tx, err := db.BeginRw(context.Background()) if err != nil { return err } defer tx.Rollback() snapshotsStageProgress, err := stages.GetStageProgress(tx, stages.Snapshots) if err != nil { return err } if snapshotsStageProgress > 0 { fPath := filepath.Join(dirs.Snap, downloader.ProhibitNewDownloadsFileName) exists, err := dir.FileExist(fPath) if err != nil { return err } if !exists { f, err := os.Create(fPath) if err != nil { return err } defer f.Close() if err := f.Sync(); err != nil { return err } } } if err := BeforeCommit(tx, nil, true); err != nil { return err } return tx.Commit() }, }
View Source
var ProhibitNewDownloadsLock2 = Migration{ Name: "prohibit_new_downloads_lock2", Up: func(db kv.RwDB, dirs datadir.Dirs, progress []byte, BeforeCommit Callback, logger log.Logger) (err error) { tx, err := db.BeginRw(context.Background()) if err != nil { return err } defer tx.Rollback() fPath := filepath.Join(dirs.Snap, downloader.ProhibitNewDownloadsFileName) exists, err := dir.FileExist(fPath) if err != nil { return err } if !exists { if err := BeforeCommit(tx, nil, true); err != nil { return err } return tx.Commit() } content, err := os.ReadFile(fPath) if err != nil { return err } if len(content) == 0 { locked := []string{} for _, t := range coresnaptype.BlockSnapshotTypes { locked = append(locked, t.Name()) } for _, t := range coresnaptype.E3StateTypes { locked = append(locked, t.Name()) } for _, t := range heimdall.SnapshotTypes() { locked = append(locked, t.Name()) } for _, t := range snaptype.CaplinSnapshotTypes { if t.Name() != snaptype.BlobSidecars.Name() { locked = append(locked, t.Name()) } } newContent, err := json.Marshal(locked) if err != nil { return err } if err := os.WriteFile(fPath, newContent, fs.FileMode(os.O_TRUNC|os.O_WRONLY)); err != nil { return err } } if err := BeforeCommit(tx, nil, true); err != nil { return err } return tx.Commit() }, }
Switch to the second version of download.lock.
Functions ¶
func AppliedMigrations ¶
Types ¶
type Migrator ¶
type Migrator struct {
Migrations []Migration
}
func NewMigrator ¶
func (*Migrator) HasPendingMigrations ¶
func (*Migrator) PendingMigrations ¶
Click to show internal directories.
Click to hide internal directories.