package flow

import (
	"flag"
	"validate/util"
)

func ShowAllStepsCommand() *ShowAllStepsCommandCtx {
	ca := &ShowAllStepsCommandCtx{
		ClusterMigrationSubCommandCtx{
			fs: flag.NewFlagSet(ShowAllMigrationStepsCommand, flag.ContinueOnError),
		},
	}
	return ca
}

type ShowAllStepsCommandCtx struct {
	ClusterMigrationSubCommandCtx
}

func (g *ShowAllStepsCommandCtx) Name() string {
	return g.fs.Name()
}

func (g *ShowAllStepsCommandCtx) Init(args []string) error {
	return g.fs.Parse(args)
}

func (g *ShowAllStepsCommandCtx) Execute() error {
	return g.ShowAllStepsMain()
}

func (g *ShowAllStepsCommandCtx) ShowAllStepsMain() error {
	util.Logger.Printf("Cluster Migration All Steps Are: \n")
	Allsteps := `
- Verify and make-up the DB accounts in the restored TiDB Cluster, while the DB account from the primary TiDB Cluster will not be restored  with the TiDB version earlier than **6.2.x**..
- Verify and make-up the SQL Binding from the primary TiDB Cluster, which is not restored and replicated  with the TiDB version earlier than **6.2.x**..
- Verify that all the schemas are identical between two TiDB Clusters if no DDL happens after the restore operation, such as databases, tables, indexes and etc.
- Verify that the replication is working in the restored TiDB Cluster, including both DMLs and DDLs. All data should be identical with the primary TiDB Cluster.
- Verify that all global variables are identical between the two TiDB Clusters. If not, fetch the value from the primary and set it to the restored TiDB Cluster.
- Verify and make-up the statistical data for Optimizer in TiDB, i.e., rebuild the system table mysql.stat_* for Optimizer to make good plan for queries.
- Verify and make-up the auto-incremental cache in the restored TiDB Cluster, which will be conflict with what is replicated from the primary TiDB Cluster.
- Verify and make-up the placement rule in the restored TiDB Cluster.
`
	util.Logger.Printf(Allsteps)

	return nil
}
