Skip to content

feat(postgres): partition planning and maintenance helpers - #67

Merged
vistart merged 4 commits into
release/v1.0.0.dev17from
feature/partition-maintenance
Nov 9, 2026
Merged

vistart merged 4 commits into
release/v1.0.0.dev17from
feature/partition-maintenance

Conversation

@vistart

@vistart vistart commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Description

Adds backend-level PostgreSQL partition planning and maintenance on the core partition plan/report contract.

  • PostgresPartitionPlan describes a flat policy or a multi-level tree: RANGE, LIST and HASH first-level branches, each branch carrying its own RangePolicy, ListPolicy or HashPolicy.
  • PostgresPartitionMaintenance and AsyncPostgresPartitionMaintenance expose ensure, list, validate, drop_before and drop_branch.
  • ensure creates only missing partitions and commits one branch unit at a time; list reads pg_inherits/pg_class recursively and keeps the server bound text verbatim; validate reports gaps, overlaps and boundary/method mismatches without repairing anything.
  • drop_before drops true leaves only and defaults to dry_run=True; drop_branch is the explicit whole-branch removal and is destructive by default.
  • Partition DDL is rendered through the existing Expression → Dialect path; the maintenance layer adds no hand-written SQL.
  • Adds English and Chinese documentation plus plan, syntax-matrix and live multi-level tests.

No tracking issue.

Type of change

  • feat: A new feature
  • docs: Documentation only changes (if related to the new feature)
  • test: Adding missing tests or correcting existing tests (for the new feature)
  • perf: A code change that improves performance (if part of the feature)
  • chore: Changes to the build process or auxiliary tools and libraries suchs as documentation generation (if related to the new feature)
  • ci: Changes to our CI configuration files and scripts (if related to the new feature)
  • build: Changes that affect the build system or external dependencies (if related to the new feature)
  • revert: Reverts a previous commit

Breaking Change

  • Yes
  • No

(If Yes, please describe the impact and migration path below):

N/A

Applicable rhosocial-activerecord Version Range:

rhosocial-activerecord>=1.0.0.dev30,<2.0.0

Related Repositories/Packages

  • Core: consumes the partition plan/report contract from core PR #130 (feature/partition-maintenance); this backend's test.yml installs core from that branch until PR #130 merges.
  • No testsuite change is required; the existing suite is installed from release/v1.0.0.dev17.

Testing

  • I have added new tests to cover my changes.
  • I have updated existing tests to reflect my changes.
  • All existing tests pass.
  • This change has been tested on [specify backend/DB versions].

Test Plan:

Local full-suite execution was skipped per the merge workflow; the repository CI matrix will run:

pytest tests/rhosocial/activerecord_postgres_test/feature/backend/postgres/test_partition_plan.py
pytest tests/rhosocial/activerecord_postgres_test/feature/backend/postgres/test_partition_syntax_matrix.py
pytest tests/rhosocial/activerecord_postgres_test/feature/backend/test_partition_multilevel.py

CI covers PostgreSQL 10/12/13/14/16/18 across Python 3.8–3.14.

Checklist

  • My code follows the project's code style guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation (Docstrings, README.md, etc.).
  • My changes generate no new warnings.
  • I have added a Changelog fragment (changelog.d/<issue_number>.<type>.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

The changelog fragment is intentionally added after CI passes, as prescribed by the merge workflow.

@vistart vistart added the enhancement New feature or request label Nov 9, 2026
@vistart vistart self-assigned this Nov 9, 2026
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.24749% with 308 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.55%. Comparing base (6bf8b72) to head (db92c69).

Files with missing lines Patch % Lines
...ord/backend/impl/postgres/partition/maintenance.py 77.08% 123 Missing and 50 partials ⚠️
...tiverecord/backend/impl/postgres/partition/plan.py 67.06% 60 Missing and 50 partials ⚠️
...verecord/backend/impl/postgres/partition/bounds.py 76.00% 10 Missing and 8 partials ⚠️
...cord/backend/impl/postgres/mixins/ddl/partition.py 50.00% 2 Missing and 2 partials ⚠️
.../backend/impl/postgres/expression/ddl/partition.py 86.66% 1 Missing and 1 partial ⚠️
...d/backend/impl/postgres/protocols/ddl/partition.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev17      #67      +/-   ##
========================================================
- Coverage                 77.77%   77.55%   -0.22%     
========================================================
  Files                       355      360       +5     
  Lines                     18140    19335    +1195     
  Branches                   2873     3173     +300     
========================================================
+ Hits                      14108    14995     +887     
- Misses                     3020     3217     +197     
- Partials                   1012     1123     +111     
Flag Coverage Δ
postgres-18 77.55% <74.24%> (-0.22%) ⬇️
python-3.14 77.55% <74.24%> (-0.22%) ⬇️
unittests 77.55% <74.24%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit 19f6eb2 into release/v1.0.0.dev17 Nov 9, 2026
15 of 17 checks passed
@vistart
vistart deleted the feature/partition-maintenance branch November 9, 2026 17:24
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

Successfully merging this pull request may close these issues.

1 participant