You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] Designer allows multiple PRIMARY KEY indexes and duplicate index names — produces invalid ALTER TABLE #384
The Indexes tab lets the user add unlimited indexes with type PRIMARY KEY. MySQL enforces a single primary key per table — ALTER TABLE x ADD PRIMARY KEY (a) after ADD PRIMARY KEY (a) raises ERROR 1068 (42000): Multiple primary key defined. Same for two indexes with the same name. The error surfaces at Save but the user has no client-side guard. There's also no validation that the columns named in a PRIMARY KEY actually exist on the table.
Add a second index with type PRIMARY KEY, columns [name]
Click Apply Changes — MySQL returns error 1068
Expected
Adding a second PRIMARY KEY index shows a yellow warning and replaces the prior one. Two indexes with the same name show an inline error. An index referencing a dropped column shows an error.
Proposed fix
Track existing PRIMARY KEYs in component state (primaryKeyColumnIds: Set); when user adds a second PRIMARY KEY index, replace the prior one (delete the old index row, add the new). Validate index name uniqueness client-side (inline error on duplicate name). Validate index columns exist in the table (error if column name not in columnNames). Scope: S.
Acceptance
Adding a second PRIMARY KEY index shows a yellow warning and replaces the prior one. Two indexes with the same name show an inline error. An index referencing a dropped column shows an error.
Already fixed — closing with the check rather than a change.
All three cases now raise an inline amber problem on the index row, before Save:
a second index of type PRIMARY KEY — "A table can have only one primary key" (ERROR 1068)
a duplicate index name (ERROR 1061)
an index naming a column that is not on the table — the case your issue mentioned last and the one that matters most, since it is what a rename leaves behind
Not implemented: silently replacing the prior primary key when a second is added. Removing something the user did not ask to remove is worse than telling them the two cannot coexist and letting them choose which.
Activity
fix(designer): stop the form building DDL the server will not take (#550
EVWorth commentedon Sep 12, 2026
Already fixed — closing with the check rather than a change.
All three cases now raise an inline amber problem on the index row, before Save:
Not implemented: silently replacing the prior primary key when a second is added. Removing something the user did not ask to remove is worse than telling them the two cannot coexist and letting them choose which.