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

Composite primary keys? #192

Open
onecrayon opened this issue Sep 27, 2022 · 3 comments
Open

Composite primary keys? #192

onecrayon opened this issue Sep 27, 2022 · 3 comments
Labels
question table-partitioning Features/bugs related to table partitioning.

Comments

@onecrayon
Copy link

We are currently evaluating partitioned tables in Postgres for use with our logging database backing a Django application (large volume of log entries that are typically filtered by date, but we only keep six months worth of data). However, one of our requirements is being able to filter log entries out based on user access (users can share access with other users), and doing a many-to-many lookup table alongside the partitioned table seemed like a sensible approach to support this.

However, if we are understanding the Postgres documentation correctly, in order to make foreign key relationships into a partitioned table, the table needs to have a composite primary key that includes the date column used to establish the partition ranges. This is problematic because Django does not support composite primary keys.

Are there any known workarounds to allow this with django-postgres-extra?

I reviewed the documentation and checked other issues, but didn't find anything specifically relevant to this (#178 was the closest related issue I located), so any guidance is appreciated!

@Photonios
Copy link
Member

Django does not support composite primary keys. You can create them manually in a migration using migrations.RunSQL.

@Photonios Photonios added table-partitioning Features/bugs related to table partitioning. question labels Feb 3, 2023
@anuj-scanova
Copy link

@onecrayon Were you able to implement partitioning? I'm facing the same issue but getting error #210

@shubhammapara
Copy link

shubhammapara commented Nov 15, 2023

Refer this thread -> #178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question table-partitioning Features/bugs related to table partitioning.
Projects
None yet
Development

No branches or pull requests

4 participants