django-postgres-extra icon indicating copy to clipboard operation
django-postgres-extra copied to clipboard

feat: support for composite/sub partitioning

Open quertenmont opened this issue 1 year ago • 1 comments

Hello,

I needed to have composite partitioning (aka nested or subpartitioning), I made the changes to make it work for one level subpartitioning.

The principal changes are:

  1. Handling "submethod" and "subkey" variable in the partitioning meta object
  2. Adding partition_by and parent_partition_name in the PostgresPartition class to make it aware that it could have either parent or child partition (and add the PARTITION OF and PARTITION BY sql statement where needed)
  3. Adding a submethod in the Config to handle how the second level should be created
  4. Updating the manager to create a second level of partition if needed

I tested the code with TimePartitioning at first level and a List partitioning at second level, it's working nicely.

The code could certainly be improved, but the functionality is there and it would certainly be useful to others to have it in the main package. Thanks for considering its inclusion.

quertenmont avatar Mar 04 '23 06:03 quertenmont