Skip to content

Restore applied migrations 0043-0045 - #1864

Merged
Asherlc merged 12 commits into
mainfrom
Asherlc/fix-climbing-data-display
Jul 22, 2026
Merged

Asherlc merged 12 commits into
mainfrom
Asherlc/fix-climbing-data-display

Conversation

@Asherlc

@Asherlc Asherlc commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • restore migrations 00430045 to the exact bytes production applied
  • document the full 73-entry production ledger audit and consumer recovery

Root cause

PR #1552 deployed its first migration versions before later commits rewrote 00420045. Production therefore recorded the initial hashes while main retained different bytes. PR #1863 restored 0042; this completes the same four-file repair.

Validation

  • all four 00420045 SHA-256 values match the production ledger exactly
  • full 73-entry ledger audit: zero missing files and zero unexpected mismatches after this restoration
  • pnpm tsx scripts/migration-policy.ts drizzle/0042_strength_set_activity_id_not_null.sql drizzle/0043_tighten_activity_strength_set_invariants.sql drizzle/0044_tighten_fk_delete_rules.sql drizzle/0045_check_constraints_and_activity_active_index.sql
  • pnpm vitest run scripts/migration-policy.test.ts src/db/postgres-migrator.test.ts (33 passing)
  • git diff --check

Summary by cubic

Restores migrations 0043–0045 to exactly match production so the migrator accepts history and deployments can proceed, unblocking the climbing activity display fix.

  • Bug Fixes
    • Replaced drizzle/00430045 with the exact bytes recorded in production, completing the 00420045 restoration.
    • Expanded the incident baseline with cited evidence: full 73-entry ledger comparison and deploy run links confirming 0042 was accepted and 0043 required the complete set.
    • Validation: all four SHA-256 hashes match production; audit reports no missing files or unexpected mismatches; tests pass.

Written for commit e37923d. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved data integrity by enforcing required fields and validating activity, workout, sleep, nutrition, and lab-result data.
    • Corrected invalid activity end times and refined body-fat percentage validation.
    • Updated record deletion behavior to maintain related data consistently.
    • Improved activity lookup performance for active records.
  • Documentation

    • Clarified production migration history, deployment verification results, and remaining follow-up items.

Copilot AI review requested due to automatic review settings July 22, 2026 19:29
@codereviewbot-ai

Copy link
Copy Markdown

🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews.

@cursor

cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Asherlc, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@Asherlc
Asherlc enabled auto-merge (squash) July 22, 2026 19:29

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR restores migrations 00420045 to production-applied content, tightens column and foreign-key invariants, changes check-constraint enforcement and backfill behavior, preserves a partial activity index, and updates the production incident timeline.

Changes

Schema hardening and migration restoration

Layer / File(s) Summary
0043 column invariants
drizzle/0043_tighten_activity_strength_set_invariants.sql
Makes strength_set.activity_id and activity.external_id non-null through direct column alterations.
0044 foreign-key delete rules
drizzle/0044_tighten_fk_delete_rules.sql
Recreates fitness foreign keys with direct enforcement, changes selected delete rules to cascade, and removes the provider foreign-key recreation.
0045 checks and active index
drizzle/0045_check_constraints_and_activity_active_index.sql
Broadens the ended_at backfill, adds checks directly, changes the DEXA body-fat constraint, and creates the partial active-activity index.
Production restoration record
docs/production-incident-baseline.md
Documents exact migration-byte restoration, ledger comparison results, deployment outcomes, replica restoration, and an additional failed-deploy reference.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • Asherlc/dofek#1552: Introduced the integrity-tightening migrations and related production incident record later restored here.

Suggested labels: area/db, type/bug, breaking-change

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning Title is clear and imperative, but it omits the required area prefix for this migration-focused change. Prefix it with the relevant area, e.g. "[db] Restore applied migrations 0043-0045".
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/production-incident-baseline.md`:
- Around line 15186-15192: Add direct primary-source links to the documentation
paragraph describing migrations 0042–0045, citing PR `#1552` for the
production-applied bytes and the ledger comparison or test evidence for the
73-entry audit and eight accepted hash variants. Keep the existing factual
claims unchanged while making each restoration and audit assertion independently
verifiable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d9968471-4cf1-4485-8843-2d470172295b

📥 Commits

Reviewing files that changed from the base of the PR and between 1fac0dc and fb81922.

📒 Files selected for processing (4)
  • docs/production-incident-baseline.md
  • drizzle/0043_tighten_activity_strength_set_invariants.sql
  • drizzle/0044_tighten_fk_delete_rules.sql
  • drizzle/0045_check_constraints_and_activity_active_index.sql

Comment thread docs/production-incident-baseline.md Outdated
@codereviewbot-ai

Copy link
Copy Markdown

🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@Asherlc
Asherlc merged commit c8c8a64 into main Jul 22, 2026
101 checks passed
@Asherlc
Asherlc deleted the Asherlc/fix-climbing-data-display branch July 22, 2026 19:50
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.

2 participants