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

Fix: no automatic foreign keys referencing partitions #3114

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

s-sokolko
Copy link

When using atlas migrate diff and the schema contains partitioned tables the autogenerated migration sometimes contains duplicate foreign key constraints. It happens when there is a foreign key in DB schema that references a partitioned table. In this case the foreign key search sql filters tables by the source table of the FK only, But we have to filter also by the target table, because if we don't the query also gives us all the partitions of tha partitioned table aprat from the partitioned table itself.
I've faced this situation using Postgres. My fix adds checks and some query formatting.

@a8m
Copy link
Member

a8m commented Sep 12, 2024

Thanks for the contribution, @s-sokolko.

However, I won’t merge this as it conflicts with our current work on supporting partitions (which should be released soon). I appreciate your effort.

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

Successfully merging this pull request may close these issues.

2 participants