{"record":{"id":"bf66bb667380b263","repo":"vitessio/vitess","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":2915,"sourceCode":"\t}\n\tresp, err := wr.VtctldServer().ValidateSchemaKeyspace(ctx, &vtctldatapb.ValidateSchemaKeyspaceRequest{\n\t\tKeyspace:       keyspace,\n\t\tExcludeTables:  excludeTableArray,\n\t\tIncludeViews:   *includeViews,\n\t\tSkipNoPrimary:  *skipNoPrimary,\n\t\tIncludeVschema: *includeVSchema,\n\t})\n\tif err != nil {\n\t\twr.Logger().Errorf(\"%s\\n\", err.Error())\n\t\treturn err\n\t}\n\n\tfor _, result := range resp.Results {\n\t\twr.Logger().Printf(\"%s\\n\", result)\n\t}\n\n\tif len(resp.Results) > 0 {\n\t\treturn fmt.Errorf(\"%s\", resp.Results[0])\n\t}\n\n\treturn nil\n}\n\nfunc commandApplySchema(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {\n\tsql := subFlags.String(\"sql\", \"\", \"A list of semicolon-delimited SQL commands\")\n\tsqlFile := subFlags.String(\"sql-file\", \"\", \"Identifies the file that contains the SQL commands\")\n\tddlStrategy := subFlags.String(\"ddl-strategy\", string(schema.DDLStrategyDirect), \"Online DDL strategy, compatible with @@ddl_strategy session variable (examples: 'direct', 'mysql', 'vitess --postpone-completion'\")\n\tuuidList := subFlags.String(\"uuid_list\", \"\", \"Optional: comma delimited explicit UUIDs for migration. If given, must match number of DDL changes\")\n\tmigrationContext := subFlags.String(\"migration_context\", \"\", \"For Online DDL, optionally supply a custom unique string used as context for the migration(s) in this command. By default a unique context is auto-generated by Vitess\")\n\trequestContext := subFlags.String(\"request_context\", \"\", \"synonym for --migration_context\")\n\twaitReplicasTimeout := subFlags.Duration(\"wait_replicas_timeout\", grpcvtctldserver.DefaultWaitReplicasTimeout, \"The amount of time to wait for replicas to receive the schema change via replication.\")\n\tbatchSize := subFlags.Int64(\"batch_size\", 0, \"How many queries to batch together\")\n\n\tcallerID := subFlags.String(\"caller_id\", \"\", \"This is the effective caller ID used for the operation and should map to an ACL name which grants this identity the necessary permissions to perform the operation (this is only necessary when strict table ACLs are used)\")\n\tif err := subFlags.Parse(args); err != nil {\n\t\treturn err","sourceCodeStart":2897,"sourceCodeEnd":2933,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L2897-L2933","documentation":"After ApplySchema runs on the VtctldServer, the response carries per-result messages. If any results were returned, the first one is treated as an error message and returned via fmt.Errorf with the raw result text. This surfaces schema-application failures (e.g. MySQL rejecting a DDL statement) as vtctl errors.","triggerScenarios":"Running `vtctldclient ApplySchema` with SQL that MySQL rejects (syntax error, duplicate column, invalid charset); partial errors reported by one or more tablets propagate to the first result string.","commonSituations":"Applying a migration with a typo'd DDL; applying DDL that conflicts with existing schema; permission problems on the underlying MySQL.","solutions":["Read the error message returned — it is the MySQL/server error text from the schema application","Fix the SQL in the --sql statements and retry","Verify tablet health and MySQL grants, then re-run ApplySchema"],"exampleFix":"// before\n--sql \"ALTER TABLE customer ADD COLUMN emial VARCHAR(255)\" -- error typo'd by MySQL\n// after\n--sql \"ALTER TABLE customer ADD COLUMN email VARCHAR(255)\"","handlingStrategy":"try-catch","validationCode":"// Dry-validate SQL before ApplySchema where possible:\n// run the DDL on a dev tablet or check syntax with the sqlparser","typeGuard":null,"tryCatchPattern":"err := applySchema(ctx, req)\nif err != nil {\n  // err text is the raw server result; log it and fix the offending SQL statement\n  log.Errorf(\"ApplySchema failed: %v\", err)\n}","preventionTips":["Test DDL against a staging keyspace first","Keep schema changes small and idempotent","Check MySQL grants for the vttablet user"],"tags":["schema","apply-schema","mysql"],"backgroundTag":"schema-application-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}