-
Notifications
You must be signed in to change notification settings - Fork 73
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
Support multi-column foreign keys #81
Comments
Hi, Firstly, I would like to express my gratitude for your efforts in developing and maintaining this valuable tool. It's been instrumental in many of my projects, and I truly appreciate the work you've put into it. I'm writing to inquire about the current support for composite keys and indexes in
are not supported for now. These features are crucial for the implementation of complex data models where single-column keys are insufficient to ensure data integrity and performance optimization. Do we have a plan on supporting these yet? Thanks. |
Thank you for your feedback! This is indeed something we want to tackle soon, as it's an important limitation. Now that we have all the foundations in place it feels like we are ready to start working on this. |
Also faced this in one of my tests:
Error: |
This isn't a pgroll limitation. Postgres doesn't support multiple PKs in a table. You can create unique constraints that function very similarly to a PK (e.g. can be the parent side of an FK relationship) but there can be only one "primary" key. |
@saintazunya I created a separate issue for your request: #409 |
…aint` (#471) This PR introduces a new constraint `type` to `create_constraint` operation called `foreign_key`. Now it is possible to create FK constraints on multiple columns. ### Examples #### Foreign key ```json { "name": "44_add_foreign_key_table_reference_constraint", "operations": [ { "create_constraint": { "type": "foreign_key", "table": "tickets", "name": "fk_sellers", "columns": [ "sellers_name", "sellers_zip" ], "references": { "table": "sellers", "columns": [ "name", "zip" ], "on_delete": "CASCADE" }, "up": { "sellers_name": "sellers_name", "sellers_zip": "sellers_zip" }, "down": { "sellers_name": "sellers_name", "sellers_zip": "sellers_zip" } } } ] } ``` Closes #81 --------- Co-authored-by: Andrew Farries <[email protected]>
The current implementation (#73 and #79) allows for foreign key constraints to be added to an individual columns, referencing one column in the target table.
This should be extended to allow foreign key constraints to be defined at the table level so they can span multiple columns.
The text was updated successfully, but these errors were encountered: