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

Support multi-column foreign keys #81

Open
andrew-farries opened this issue Sep 5, 2023 · 3 comments
Open

Support multi-column foreign keys #81

andrew-farries opened this issue Sep 5, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@andrew-farries
Copy link
Collaborator

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.

@saintazunya
Copy link

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 pgroll. Based on my experiances, not only foreign keys are not supported, but also

  • Composite Primary Keys
  • Composite Unique Keys
  • Composite Indexes

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.

@exekias
Copy link
Member

exekias commented Nov 10, 2023

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.

@SferaDev
Copy link
Member

Also faced this in one of my tests:

CREATE TABLE IF NOT EXISTS "users_to_groups" (
        "id" serial PRIMARY KEY NOT NULL,
        "user_id" integer NOT NULL,
        "group_id" integer NOT NULL,
        CONSTRAINT "users_to_groups_group_id_user_id_pk" PRIMARY KEY("group_id","user_id")
);

Error: unable to execute start operation: pq: multiple primary keys for table "users_to_groups" are not allowed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants