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
In a vitess migration, we programmatically create a shadow table that is a duplicate of the original table, but with a another name. We take care of renaming any constraints as those must be unique across the schema and otherwise copy any foreign key definitions as-is.
However, in the case of a self-referencing foreign key, we must rename the referenced table name to match the shadow table. To illustrate, if we duplicate table t as _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_, then this statement:
createtablet (id intprimary key, i int, constraint f foreign key (i) references t (id))
Is today rewritten as:
createtable_vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ (id intprimary key, i int, constraint f foreign key (i) references t (id))
But should turn into:
createtable_vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ (id intprimary key, i int, constraint f foreign key (i) references _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ (id))
Reproduction Steps
Run Online DDL vitess migration (e.g. add any column) on a self referencing foreign key table.
Binary Version
current, 20, 19, 18
Operating System and Environment details
-
Log Fragments
No response
The text was updated successfully, but these errors were encountered:
Overview of the Issue
In a
vitess
migration, we programmatically create a shadow table that is a duplicate of the original table, but with a another name. We take care of renaming any constraints as those must be unique across the schema and otherwise copy any foreign key definitions as-is.However, in the case of a self-referencing foreign key, we must rename the referenced table name to match the shadow table. To illustrate, if we duplicate table
t
as_vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_
, then this statement:Is today rewritten as:
But should turn into:
Reproduction Steps
Run Online DDL vitess migration (e.g. add any column) on a self referencing foreign key table.
Binary Version
Operating System and Environment details
Log Fragments
No response
The text was updated successfully, but these errors were encountered: