Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-ost is reporting wrong the number of multi-columns FK #1328

Open
abonacin opened this issue Oct 19, 2023 · 0 comments
Open

gh-ost is reporting wrong the number of multi-columns FK #1328

abonacin opened this issue Oct 19, 2023 · 0 comments

Comments

@abonacin
Copy link

gh-ost is reporting:
ERROR Found 2 parent-side foreign keys on employees.countries. Parent-side foreign keys are not supported. Bailing out

mysql> SELECT SUM(REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_SCHEMA='employees' AND TABLE_NAME='countries') as num_child_side_fk,
    ->        SUM(REFERENCED_TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_SCHEMA='employees' AND REFERENCED_TABLE_NAME='countries') as num_parent_side_fk
    -> FROM   INFORMATION_SCHEMA.KEY_COLUMN_USAGE
    -> WHERE  REFERENCED_TABLE_NAME IS NOT NULL
    -> AND    ((TABLE_SCHEMA='employees' AND TABLE_NAME='countries') OR (REFERENCED_TABLE_SCHEMA='employees' AND REFERENCED_TABLE_NAME='countries'));
+-------------------+--------------------+
| num_child_side_fk | num_parent_side_fk |
+-------------------+--------------------+
|                 0 |                  2 |
+-------------------+--------------------+
1 row in set (0.00 sec)

But it is a 2-columns FK

mysql> SELECT refcons.constraint_schema,
    ->        refcons.table_name,
    ->        refcons.referenced_table_name,
    ->        refcons.constraint_name,
    ->        keycol.column_name
    -> FROM   information_schema.referential_constraints refcons
    -> JOIN   information_schema.key_column_usage keycol
    -> ON     refcons.constraint_schema = keycol.table_schema
    -> AND    refcons.table_name = keycol.table_name
    -> AND    refcons.constraint_name = keycol.constraint_name
    -> WHERE  refcons.constraint_schema = 'employees'
    -> AND    refcons.referenced_table_name = 'countries';
+-------------------+------------+-----------------------+-----------------+-------------+
| CONSTRAINT_SCHEMA | TABLE_NAME | REFERENCED_TABLE_NAME | CONSTRAINT_NAME | COLUMN_NAME |
+-------------------+------------+-----------------------+-----------------+-------------+
| employees         | cities     | countries             | cit_count_fk    | country_id  |
| employees         | cities     | countries             | cit_count_fk    | cod_empresa |
+-------------------+------------+-----------------------+-----------------+-------------+
2 rows in set (0.00 sec)
abonacin added a commit to abonacin/gh-ost that referenced this issue Oct 19, 2023
github#1328 - Removing duplicate values for multi-column FK
abonacin added a commit to abonacin/gh-ost that referenced this issue Oct 19, 2023
github#1328 - Removing duplicate values for multi-column FK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant