vitessio/vitess · error
found no possible unique key on `%s` whose columns are in ta
Error message
found no possible unique key on `%s` whose columns are in target table `%s`
What it means
During OnlineDDLMigrationTablesAnalysis, the source table's unique keys are filtered to those whose columns all exist in the target table (VReplication requires this so the key can be evaluated on both sides). If every source unique key references at least one column absent from the target, the analysis fails. This is a cross-table compatibility check, not a mere presence check.
Source
Thrown at go/vt/schemadiff/onlineddl.go:563
analysis.SourceSharedColumns, analysis.TargetSharedColumns, droppedSourceNonGeneratedColumns, analysis.SharedColumnsMap = AnalyzeSharedColumns(sourceColumns, targetColumns, alterTableAnalysis)
// unique keys
sourceUniqueKeys := PrioritizedUniqueKeys(sourceCreateTableEntity)
if sourceUniqueKeys.Len() == 0 {
return nil, fmt.Errorf("found no possible unique key on `%s`", sourceCreateTableEntity.Name())
}
targetUniqueKeys := PrioritizedUniqueKeys(targetCreateTableEntity)
if targetUniqueKeys.Len() == 0 {
return nil, fmt.Errorf("found no possible unique key on `%s`", targetCreateTableEntity.Name())
}
// VReplication supports completely different unique keys on source and target, covering
// some/completely different columns. The condition is that the key on source
// must use columns which all exist on target table.
eligibleSourceColumnsForUniqueKey := analysis.SourceSharedColumns.Union(generatedColumns(sourceColumns))
analysis.ChosenSourceUniqueKey = IterationKeysByColumns(sourceUniqueKeys, eligibleSourceColumnsForUniqueKey).First()
if analysis.ChosenSourceUniqueKey == nil {
return nil, fmt.Errorf("found no possible unique key on `%s` whose columns are in target table `%s`", sourceCreateTableEntity.Name(), targetCreateTableEntity.Name())
}
eligibleTargetColumnsForUniqueKey := analysis.TargetSharedColumns.Union(generatedColumns(targetColumns))
analysis.ChosenTargetUniqueKey = IterationKeysByColumns(targetUniqueKeys, eligibleTargetColumnsForUniqueKey).First()
if analysis.ChosenTargetUniqueKey == nil {
return nil, fmt.Errorf("found no possible unique key on `%s` whose columns are in source table `%s`", targetCreateTableEntity.Name(), sourceCreateTableEntity.Name())
}
analysis.AddedUniqueKeys = IntroducedUniqueConstraints(sourceUniqueKeys, targetUniqueKeys, alterTableAnalysis.ColumnRenameMap)
analysis.RemovedUniqueKeys = RemovedUniqueConstraints(sourceUniqueKeys, targetUniqueKeys, alterTableAnalysis.ColumnRenameMap)
analysis.RemovedForeignKeyNames, err = RemovedForeignKeyNames(sourceCreateTableEntity, targetCreateTableEntity)
if err != nil {
return nil, err
}
formalizeColumns := func(columnsLists ...*ColumnDefinitionEntityList) error {
for _, colList := range columnsLists {
for _, col := range colList.Entities {View on GitHub (pinned to 01a25a7d17)
Solutions
- Ensure the source's unique key columns exist on the target (add them back or keep the column)
- Register the column rename in the ALTER TABLE RENAME COLUMN so shared-column analysis maps it
- Choose a different source unique key whose columns are shared with the target
Example fix
-- before (target lacks 'email' used by source unique key) ALTER TABLE t DROP COLUMN email; -- after ALTER TABLE t CHANGE COLUMN email contact VARCHAR(255);
Defensive patterns
Strategy: validation
Validate before calling
shared := analysis.SourceSharedColumns
for _, col := range chosenSourceUniqueKey.Columns { if !shared.Contains(col) { /* column missing on target */ } } Prevention
- Keep unique-key columns shared between source and target
- Always express column changes as RENAME COLUMN when renaming
- Diff source/target schemas before migration
When it happens
Trigger: Calling OnlineDDLMigrationTablesAnalysis when the source table has unique keys but none of them is contained within analysis.SourceSharedColumns ∪ generated columns of the source — i.e. the chosen/matching target schema dropped or renamed a column used by all source unique keys.
Common situations: A column rename done without the rename map knowing about it; target table created from a subset of source columns; a migration that drops a column participating in the source's only unique key.
Related errors
- found no possible unique key on `%s` whose columns are in so
- found no possible unique key on `%s`
- value out of range
- mismatched entity type
- strict index ordering is unsupported
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/e345a763d1815ed9.
Report an issue: GitHub.