mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
1128753069
[DOCS-520]: https://hasurahq.atlassian.net/browse/DOCS-520?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [DOCS-520]: https://hasurahq.atlassian.net/browse/DOCS-520?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7419 GitOrigin-RevId: 52e8e54bf7068ee91fce19831db99d7a24afb00c
53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hasura/graphql-engine/cli/v2"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/errors"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/projectmetadata"
|
|
|
|
"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 Hasura Metadata",
|
|
Long: `At times, when developing, the Hasura Metadata can become inconsistent. This command can be used to drop inconsistent objects from the Hasura Metadata and bring your project's Metadata back to a consistent state.
|
|
|
|
Further reading:
|
|
- https://hasura.io/docs/latest/migrations-metadata-seeds/resetting-migrations-metadata/
|
|
`,
|
|
SilenceUsage: true,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
op := genOpName(cmd, "RunE")
|
|
opts.EC.Spin("Dropping inconsistent metadata...")
|
|
err := opts.run()
|
|
opts.EC.Spinner.Stop()
|
|
if err != nil {
|
|
return errors.E(op, fmt.Errorf("failed to drop inconsistent metadata: %w", err))
|
|
}
|
|
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 {
|
|
var op errors.Op = "commands.metadataInconsistencyDropOptions.run"
|
|
if err := projectmetadata.NewHandlerFromEC(o.EC).DropInconsistentMetadata(); err != nil {
|
|
return errors.E(op, err)
|
|
}
|
|
return nil
|
|
}
|