Skip to content

Conversation

@marcodejongh
Copy link
Owner

Summary

Fixes database migration failure caused by orphaned data violating foreign key constraints.

Problem

The migration 0025_shocking_clint_barton.sql was failing on production with:

insert or update on table "board_beta_links" violates foreign key constraint "board_beta_links_climb_fk"
Key (climb_uuid)=(ED7DB8424C5543129C05C9EB82B701D9) is not present in table "board_climbs".

Solution

Add DELETE statements to clean up orphaned records before adding FK constraints:

  • board_beta_links with missing climb_uuid
  • board_circuits_climbs with missing climb_uuid
  • board_climb_holds with missing climb_uuid
  • board_climb_stats with missing climb_uuid

Testing

  • Migration runs successfully on local database

🤖 Generated with Claude Code

Add DELETE statements to remove orphaned records before adding foreign
key constraints in the unified tables migration. This fixes migration
failures when orphaned data exists (e.g., beta_links referencing
non-existent climbs).

Orphaned data cleaned:
- board_beta_links with missing climb_uuid
- board_circuits_climbs with missing climb_uuid
- board_climb_holds with missing climb_uuid
- board_climb_stats with missing climb_uuid

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
boardsesh Building Building Preview, Comment Jan 4, 2026 6:10am

@marcodejongh marcodejongh merged commit da45092 into main Jan 4, 2026
3 of 6 checks passed
@claude
Copy link

claude bot commented Jan 4, 2026

Claude Review

Ready to merge - The fix correctly addresses the orphaned data issue by adding DELETE statements for all four tables that receive FK constraints on climb_uuid.

No significant issues found. The cleanup statements properly handle orphaned records in board_beta_links, board_circuits_climbs, board_climb_holds, and board_climb_stats before the FK constraints are added. The board_climb_stats_history table is correctly excluded from cleanup since it doesn't have an FK constraint (history tables typically don't enforce referential integrity).

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