mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
4c19e622cd
* rollback logic * implement up down logic * begin down migration tests * rollback works * unset test * remove iface * gaz * add comment * fix ineff assign * preston comment * add progress
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package db
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
|
"github.com/prysmaticlabs/prysm/shared/tos"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// DatabaseCommands for Prysm validator.
|
|
var DatabaseCommands = &cli.Command{
|
|
Name: "db",
|
|
Category: "db",
|
|
Usage: "defines commands for interacting with eth2 validator database",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "restore",
|
|
Description: `restores a database from a backup file`,
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
cmd.RestoreSourceFileFlag,
|
|
cmd.RestoreTargetDirFlag,
|
|
}),
|
|
Before: tos.VerifyTosAcceptedOrPrompt,
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := restore(cliCtx); err != nil {
|
|
log.Fatalf("Could not restore database: %v", err)
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
Name: "migrate",
|
|
Category: "db",
|
|
Usage: "Defines commands for running validator database migrations",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "up",
|
|
Usage: "Runs up migrations for the validator database",
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
cmd.DataDirFlag,
|
|
}),
|
|
Before: tos.VerifyTosAcceptedOrPrompt,
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := migrateUp(cliCtx); err != nil {
|
|
log.Fatalf("Could not run database migrations: %v", err)
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
Name: "down",
|
|
Usage: "Runs down migrations for the validator database",
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
cmd.DataDirFlag,
|
|
}),
|
|
Before: tos.VerifyTosAcceptedOrPrompt,
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := migrateDown(cliCtx); err != nil {
|
|
log.Fatalf("Could not run database migrations: %v", err)
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|