[PostgreSQL] The best approach to create composite primary key #1135
Replies: 2 comments 1 reply
-
@baltic-tea The issue with adding a composite unique constraint to multiple columns at once will be resolved by this PR. For now, the workaround is to use raw sql (in migrations or script) to add a composite unique constraint, as described here. pip install https://github.com/sinisaos/piccolo/archive/dev.zip I hope that helps you. |
Beta Was this translation helpful? Give feedback.
-
Piccolo ORM does not currently support composite primary keys directly via model definitions. As shown in your example, trying to mark multiple fields as primary_key=True leads to the InvalidTableDefinitionError.
Let me know if you want a workaround using SQLAlchemy for that part. |
Beta Was this translation helpful? Give feedback.
-
What is the best approach to create a composite primary key in piccolo-orm?
Sample PostgreSQL table (DDL):
An exception raises during the creation of a table with the following object structure:
Beta Was this translation helpful? Give feedback.
All reactions