dialect/sql/schema: skip creating unique key for primary keys (#2425)

This commit is contained in:
Ariel Mashraki
2022-03-24 18:53:36 +02:00
committed by GitHub
parent c00b4ecb0f
commit 6c30ca7d4f
2 changed files with 20 additions and 3 deletions

View File

@@ -490,7 +490,7 @@ func (m *Migrate) aColumns(b atBuilder, t1 *Table, t2 *schema.Table) error {
}
c2.SetDefault(&schema.RawExpr{X: x})
}
if c1.Unique {
if c1.Unique && (len(t1.PrimaryKey) != 1 || t1.PrimaryKey[0] != c1) {
b.atUniqueC(t1, c1, t2, c2)
}
if c1.Increment {