partitioning.py 685 B

1234567891011121314151617181920212223
  1. from dateutil.relativedelta import relativedelta
  2. from psqlextra.partitioning import (
  3. PostgresCurrentTimePartitioningStrategy,
  4. PostgresPartitioningManager,
  5. PostgresTimePartitionSize,
  6. partition_by_current_time,
  7. )
  8. from psqlextra.partitioning.config import PostgresPartitioningConfig
  9. from apps.issue_events.models import IssueEvent
  10. manager = PostgresPartitioningManager(
  11. [
  12. PostgresPartitioningConfig(
  13. model=IssueEvent,
  14. strategy=PostgresCurrentTimePartitioningStrategy(
  15. size=PostgresTimePartitionSize(weeks=1),
  16. count=2,
  17. max_age=relativedelta(months=3),
  18. ),
  19. ),
  20. ]
  21. )