Skip to content

feat(db): partition collab update batches#365

Merged
KurodaKayn merged 5 commits into
mainfrom
feat/collab-batch-hash-partitions
Jun 23, 2026
Merged

feat(db): partition collab update batches#365
KurodaKayn merged 5 commits into
mainfrom
feat/collab-batch-hash-partitions

Conversation

@KurodaKayn

Copy link
Copy Markdown
Owner

Feature Description

  • Adds PostgreSQL schema initialization for 16-way hash partitioning of collab_document_update_batches by document_id.
  • Keeps collaborative batch uniqueness document-local while making the partitioned table constraints PostgreSQL-compatible.
  • Updates the Phase 4 database optimization plan to mark collaborative batch hash partitioning complete.

Implementation Approach

  • Creates partitioned parent DDL before AutoMigrate and ensures all hash partitions exist idempotently.
  • Migrates an existing regular collab_document_update_batches table into the partitioned target and syncs the serial sequence after copying rows.
  • Updates the Go model primary key to include document_id and adds DB tests for the partition contract.

Testing

  • golangci-lint run from backend/: passed.
  • bash script/ci/backend.sh: passed.

Risks

  • Existing PostgreSQL environments will rename and copy the current collab batch table during schema sync; review migration timing for large tables before production rollout.

Collaborative update batches can grow quickly and need document-local partitioning before cold archiving.

Add PostgreSQL schema initialization for a 16-way document_id hash partitioned collab batch table and migrate existing rows into the partitioned target.

The batch table primary key now includes document_id so PostgreSQL partition constraints remain valid.
The collaborative batch partitioning schema needs regression coverage around PostgreSQL partition constraints.

Add DB tests for the partition-compatible primary key, hash partition DDL, and collab batch partition definition.

The checks pin the document_id hash partition shape used by schema initialization.
The Phase 4 plan should reflect that collaborative batch hash partitioning now has an implementation entry point.

Mark the collab_document_update_batches document_id hash partition item complete and update the status matrix and progress estimate.

The remaining Phase 4 work is now cold partition export and archive recovery.
Existing collab batch tables keep their serial sequence name after the table is renamed during partition migration.

Rename the legacy-owned id sequence before creating the new partitioned parent so bigserial can create its expected sequence.

Startup schema migration now avoids the sequence-name collision on databases with preexisting collab batches.
The collab batch partition migration needs coverage for the serial sequence name left behind by existing tables.

Assert that legacy migration SQL finds the owned id sequence and renames it away from the new partitioned parent name.

The regression check protects the startup migration from reintroducing the bigserial sequence collision.
@KurodaKayn KurodaKayn merged commit 63b7517 into main Jun 23, 2026
14 checks passed
@KurodaKayn KurodaKayn deleted the feat/collab-batch-hash-partitions branch June 23, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant