-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schemadiff: validate and apply foreign key indexes (#12026)
* more testing for getViewDependentTableNames() Signed-off-by: Shlomi Noach <[email protected]> * getForeignKeyParentTableNames Signed-off-by: Shlomi Noach <[email protected]> * schema normalization: sort tables by fk reference order Signed-off-by: Shlomi Noach <[email protected]> * minor test addition Signed-off-by: Shlomi Noach <[email protected]> * ForeignKeyDependencyUnresolvedError Signed-off-by: Shlomi Noach <[email protected]> * InvalidReferencedColumnInForeignKeyConstraintError, MismatchingForeignKeyColumnCountError, MismatchingForeignKeyColumnTypeError Signed-off-by: Shlomi Noach <[email protected]> * validate or autogenerate index on local table based on foreign key constraint columns Signed-off-by: Shlomi Noach <[email protected]> * validate referenced table key Signed-off-by: Shlomi Noach <[email protected]> * ColumnKeyOption consts become public Signed-off-by: Shlomi Noach <[email protected]> * adding DuplicateKeyNameError Signed-off-by: Shlomi Noach <[email protected]> * normalize PRIMARY KEY definition: a 'id int primary key' column definition splits into 'id int' and 'primary key (id)' parts. Primary key is always the first key in the list of keys. Handle queries such as 'modify id int primary key' (validate there isn't already a primary key, or that the existing primary key is over 'id'. add column with primary key definition... Signed-off-by: Shlomi Noach <[email protected]> * further unit test adaptations Signed-off-by: Shlomi Noach <[email protected]> * adapting tests: adding required local index over foreign key columns Signed-off-by: Shlomi Noach <[email protected]> * implicitly add key over foreign key columns if no appropriate key exists Signed-off-by: Shlomi Noach <[email protected]> * normalize CREATE TABLE statement to include missing foreign key indexes Signed-off-by: Shlomi Noach <[email protected]> * rename error: ForeignKeyColumnCountMismatchError Signed-off-by: Shlomi Noach <[email protected]> * rename MismatchingForeignKeyColumnTypeError to ForeignKeyColumnTypeMismatchError Signed-off-by: Shlomi Noach <[email protected]> * changes per review Signed-off-by: Shlomi Noach <[email protected]> * add a few tests that validate an implicit index isn't added if not needed Signed-off-by: Shlomi Noach <[email protected]> * case insensitive column comparison in indexCoversColumnsInOrder and in tests Signed-off-by: Shlomi Noach <[email protected]> * MissingForeignKeyIndexError is not needed bcause, compatible with MySQL behavior, we implicitly add the index if missing Signed-off-by: Shlomi Noach <[email protected]> --------- Signed-off-by: Shlomi Noach <[email protected]>
- Loading branch information
1 parent
f33b862
commit ae8406d
Showing
5 changed files
with
372 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.