Skip to content

Comments

fix partition migration: drop conflicting index and recover from part…#3

Merged
9cb14c1ec0 merged 1 commit intomasterfrom
user-id
Feb 19, 2026
Merged

fix partition migration: drop conflicting index and recover from part…#3
9cb14c1ec0 merged 1 commit intomasterfrom
user-id

Conversation

@9cb14c1ec0
Copy link
Owner

@9cb14c1ec0 9cb14c1ec0 commented Feb 19, 2026

…ial runs

The migration failed because idx_logs_team_id_id (created by migration 001) kept its name after the table was renamed to logs_old, blocking the CREATE INDEX on the new partitioned table. Adds a DROP INDEX before re-creating it and recovery logic that detects a partially-applied state (logs_old exists) and rolls back before retrying.

Summary by CodeRabbit

  • Refactor
    • Optimized log data management infrastructure to improve system reliability and query performance.

…ial runs

The migration failed because idx_logs_team_id_id (created by migration 001)
kept its name after the table was renamed to logs_old, blocking the CREATE
INDEX on the new partitioned table. Adds a DROP INDEX before re-creating it
and recovery logic that detects a partially-applied state (logs_old exists)
and rolls back before retrying.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@9cb14c1ec0 9cb14c1ec0 merged commit 51ece03 into master Feb 19, 2026
@9cb14c1ec0 9cb14c1ec0 deleted the user-id branch February 19, 2026 15:05
@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This migration enhances the table partitioning process by adding a recovery mechanism to handle partially applied migrations, a pre-check to skip if partitioning already exists, and removal of a conflicting index before restructuring the logs table for team-based partitioning.

Changes

Cohort / File(s) Summary
Database Migration Enhancement
backend/migrations/002_partition_logs_by_team.sql
Adds recovery logic to detect and rollback incomplete migration runs; introduces a pre-check using pg_partitioned_table to skip if logs table is already partitioned; drops the idx_logs_team_id_id index before renaming the table to prevent conflicts with the new partitioned structure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • 9cb14c1ec0/SimpleLogs#2: Implements the initial per-team/monthly partitioning logic for the logs table; this PR extends it with recovery paths and safety checks to handle partial failures.

Poem

🐰✨ A migration's tale takes a safer turn,
With recovery paths so the database won't burn,
Pre-checks and indices we gently release,
Partitions take shape—now logs flow with ease! 🗂️

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch user-id

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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