2021-04-20 00:58:05 +03:00
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
2021-07-24 11:28:05 +07:00
|
|
|
"context"
|
|
|
|
|
2021-07-29 18:53:13 +07:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
2021-04-20 00:58:05 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var removeCliqueBucket = Migration{
|
|
|
|
Name: "remove_clique_bucket",
|
2021-07-28 09:47:38 +07:00
|
|
|
Up: func(db kv.RwDB, tmpdir string, progress []byte, BeforeCommit Callback) (err error) {
|
2021-07-24 11:28:05 +07:00
|
|
|
tx, err := db.BeginRw(context.Background())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer tx.Rollback()
|
2021-04-20 00:58:05 +03:00
|
|
|
|
2021-07-28 10:43:51 +07:00
|
|
|
if exists, err := tx.ExistsBucket(kv.Clique); err != nil {
|
2021-04-20 00:58:05 +03:00
|
|
|
return err
|
|
|
|
} else if !exists {
|
2021-07-24 11:28:05 +07:00
|
|
|
if err := BeforeCommit(tx, nil, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tx.Commit()
|
2021-04-20 00:58:05 +03:00
|
|
|
}
|
|
|
|
|
2021-07-28 10:43:51 +07:00
|
|
|
if err := tx.DropBucket(kv.Clique); err != nil {
|
2021-04-20 00:58:05 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-07-24 11:28:05 +07:00
|
|
|
if err := BeforeCommit(tx, nil, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tx.Commit()
|
2021-04-20 00:58:05 +03:00
|
|
|
},
|
|
|
|
}
|