graphql-engine/cli/commands/metadata_inconsistency_drop.go
Aravind K P f6ca551df4 cli: support mssql sources
GitOrigin-RevId: 4b1a63c8dc342ae4001b16c4b1dce282092d5c6f
2021-03-08 12:00:34 +00:00

45 lines
1.1 KiB
Go

package commands
import (
"github.com/hasura/graphql-engine/cli"
"github.com/hasura/graphql-engine/cli/internal/hasura"
"github.com/hasura/graphql-engine/cli/migrate"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func newMetadataInconsistencyDropCmd(ec *cli.ExecutionContext) *cobra.Command {
opts := &metadataInconsistencyDropOptions{
EC: ec,
}
metadataInconsistencyDropCmd := &cobra.Command{
Use: "drop",
Short: "Drop inconsistent objects from the metadata",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
opts.EC.Spin("Dropping inconsistent metadata...")
err := opts.run()
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to drop inconsistent metadata")
}
opts.EC.Logger.Info("all inconsistent objects removed from metadata")
return nil
},
}
return metadataInconsistencyDropCmd
}
type metadataInconsistencyDropOptions struct {
EC *cli.ExecutionContext
}
func (o *metadataInconsistencyDropOptions) run() error {
d, err := migrate.NewMigrate(o.EC, true, "", hasura.SourceKindPG)
if err != nil {
return err
}
return d.DropInconsistentMetadata()
}