{"record":{"id":"d2417d260d7426aa","repo":"vitessio/vitess","slug":"target-table-v-does-not-exist-and-there-is-no-cre","errorCode":null,"errorMessage":"target table %v does not exist and there is no create ddl defined","messagePattern":"target table (.+?) does not exist and there is no create ddl defined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/materializer.go","lineNumber":1186,"sourceCode":"\t\t}\n\n\t\tfor _, td := range targetSchema.TableDefinitions {\n\t\t\thasTargetTable[td.Name] = true\n\t\t}\n\n\t\ttargetTablet, err := mz.wr.ts.GetTablet(ctx, target.PrimaryAlias)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tvar applyDDLs []string\n\t\tfor _, ts := range mz.ms.TableSettings {\n\t\t\tif hasTargetTable[ts.TargetTable] {\n\t\t\t\t// Table already exists.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ts.CreateDdl == \"\" {\n\t\t\t\treturn fmt.Errorf(\"target table %v does not exist and there is no create ddl defined\", ts.TargetTable)\n\t\t\t}\n\n\t\t\tvar err error\n\t\t\tmu.Lock()\n\t\t\tif len(sourceDDLs) == 0 {\n\t\t\t\t// only get ddls for tables, once and lazily: if we need to copy the schema from source to target\n\t\t\t\t// we copy schemas from primaries on the source keyspace\n\t\t\t\t// and we have found use cases where user just has a replica (no primary) in the source keyspace\n\t\t\t\tsourceDDLs, err = mz.getSourceTableDDLs(ctx)\n\t\t\t}\n\t\t\tmu.Unlock()\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(\"Error getting DDLs of source tables: \" + err.Error())\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tcreateDDL := ts.CreateDdl\n\t\t\tif createDDL == createDDLAsCopy || createDDL == createDDLAsCopyDropConstraint || createDDL == createDDLAsCopyDropForeignKeys {","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/materializer.go#L1168-L1204","documentation":"During deploySchema, each TableSettings entry must end up with a CREATE statement on the target. If the target table does not exist yet and ts.CreateDdl is empty, the materializer has no way to create it, so it fails with this error.","triggerScenarios":"MoveTables/Materialize workflow created with a table in --tables/-t (or TableSettings) whose TargetTable does not already exist in the target keyspace, and no CreateDdl (or --create-ddl) was specified.","commonSituations":"Starting MoveTables into an empty target keyspace without passing --create-ddl=copy; typo in the target table name so it looks nonexistent; target table was dropped between workflow creation and schema deployment.","solutions":["Create the workflow with `--create-ddl=copy` (copies DDL from the source primary), or `--create-ddl=copy-drop-constraints` / `copy-drop-foreign-keys`","Or specify an explicit CREATE TABLE statement via CreateDdl in the MaterializeSettings / --create-ddl flag","Or pre-create the target table manually with the correct schema before starting the workflow"],"exampleFix":"// before\nvtctldclient MoveTables --target-keyspace=commerce create --source-keyspace=inventory --tables='customer'\n// after\nvtctldclient MoveTables --target-keyspace=commerce create --source-keyspace=inventory --tables='customer' --create-ddl='copy'","handlingStrategy":"validation","validationCode":"ts, err := wr.ts.GetTablet(ctx, targetPrimaryAlias) // fetch target schema beforehand\nschema, _ := schematools.GetSchema(ctx, wr.ts, wr.tmc, targetPrimaryAlias, &tabletmanagerdatapb.GetSchemaRequest{Tables: []string{\"/.*/\"}})\nfor _, tbl := range tables {\n    if !contains(schema.TableDefinitions, tbl) && createDdl == \"\" {\n        return fmt.Errorf(\"table %s missing on target and no create-ddl given\", tbl)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --create-ddl (e.g. 'copy') when target keyspace may be empty","Pre-create target tables if you need custom DDL","Double-check table name spellings in --tables"],"tags":["vitess","wrangler","schema-copy","misconfiguration"],"backgroundTag":"missing-create-ddl","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}