// CheckOperations try to check and fix all the schema and table names for operation infos.
CheckOperations try to check and fix all the schema and table names for operation infos.
// CheckOperations try to check and fix all the schema and table names for operation infos .
func CheckOperations(cli *clientv3.Client, source string, schemaMap map[string]string, tablesMap map[string]map[string]string) error {
	allOperations, rev, err := GetAllOperations(cli)
	if err != nil {
		return err
	}
	for _, taskTableOps := range allOperations {
		sourceOps, ok := taskTableOps[source]
		if !ok {
			continue
		}
		for schema, tblOps := range sourceOps {
			realSchema, hasChange := schemaMap[schema]
			if !hasChange {
				realSchema = schema
			}
			tblMap := tablesMap[schema]
			for tbl, info := range tblOps {
				realTable, tblChange := tblMap[tbl]
				if !tblChange {
					realTable = tbl
					tblChange = hasChange
				}
				if tblChange {
					newOperation := info
					newOperation.UpSchema = realSchema
					newOperation.UpTable = realTable
					_, _, err = PutOperation(cli, false, newOperation, rev)
					if err != nil {
						return err
					}
					deleteOp := deleteOperationOp(info)
					_, _, err = etcdutil.DoOpsInOneTxnWithRetry(cli, deleteOp)
					if err != nil {
						return err
					}
				}
			}
		}
	}
	return err
}
func CheckOperations ( cli * clientv3 . Client , source string , schemaMap map [ string ] string , tablesMap map [ string ] map [ string ] string ) error { allOperations , rev , err := GetAllOperations ( cli ) if err != nil { return err } for _ , taskTableOps := range allOperations { sourceOps , ok := taskTableOps [ source ] if ! ok { continue } for schema , tblOps := range sourceOps { realSchema , hasChange := schemaMap [ schema ] if ! hasChange { realSchema = schema } tblMap := tablesMap [ schema ] for tbl , info := range tblOps { realTable , tblChange := tblMap [ tbl ] if ! tblChange { realTable = tbl tblChange = hasChange } if tblChange { newOperation := info newOperation . UpSchema = realSchema newOperation . UpTable = realTable _ , _ , err = PutOperation ( cli , false , newOperation , rev ) if err != nil { return err } deleteOp := deleteOperationOp ( info ) _ , _ , err = etcdutil . DoOpsInOneTxnWithRetry ( cli , deleteOp ) if err != nil { return err } } } } } return err }
CheckOperations try to check and fix all the schema and table names for operation infos.
CheckOperations try to check and fix all the schema and table names for operation infos .