Skip to content

hotfix(migrations): fix 4 duplicate LLC Alembic revision IDs + FK chain (#8460 v2) - #8466

Merged
mrveiss merged 2 commits into
Dev_new_guifrom
hotfix/llc-migration-chain-v2
May 23, 2026
Merged

mrveiss merged 2 commits into
Dev_new_guifrom
hotfix/llc-migration-chain-v2

Conversation

@mrveiss

@mrveiss mrveiss commented May 23, 2026

Copy link
Copy Markdown
Owner

Problem

Three LLC migrations were merged concurrently with identical revision = "20260523_022", breaking alembic upgrade head. A first attempt (PR #8460) was created but became conflicting when 6091fb4a5 (GH#8215 budget enforcement) landed on Dev_new_gui with down_revision = "20260523_022".

Fix

Establishes a correct linear chain:

021 (heartbeat_wakeup)             — existing anchor
022 (create_llc_work_items)        — table only; FK to llc_goals deferred
023 (organization_llc_extensions)  — no LLC FK deps
024 (llc_goals)                    — creates table + wires fk_llc_work_items_goal_id
025 (llc_agent_budgets)            — down_revision = 024 (corrected from 022)

Files renamed (022_organization_llc_extensions → 023_*, 022_llc_goals → 024_*) with matching revision / down_revision updates.

The FK from llc_work_items.goal_id → llc_goals.id could not live in migration 022 (goals table didn't exist yet). It is deferred to 024_llc_goals.py which runs after both tables exist — ensuring CREATE TABLE succeeds and alembic downgrade tears down in reverse order cleanly.

Downgrade safety

Migration downgrade action
025 drop llc_agent_budget_events, llc_budget_limits
024 drop FK constraint → drop llc_goals
023 remove columns from organizations
022 drop llc_work_item_comments, llc_work_items

Unblocks

🤖 Generated with Claude Code

mrveiss and others added 2 commits May 23, 2026 13:31
…3_022)

Four LLC migrations were merged with identical revision = "20260523_022",
breaking alembic upgrade head. Creates a linear chain:

  021 (heartbeat_wakeup)
  → 022 (create_llc_work_items)  [unchanged anchor]
  → 023 (organization_llc_extensions)  [renamed from 022, GH#8211]
  → 024 (llc_goals)              [renamed from 022, GH#8212]
  → 025 (llc_agent_budgets)      [renamed from 022, GH#8215]

All pending LLC migration PRs must rebase and use revision 026+ with
down_revision = "20260523_025".

Co-Authored-By: Paperclip <noreply@paperclip.ing>
… chain

Migration 022 referenced llc_goals.id via inline ForeignKey, but llc_goals
is not created until migration 024. This caused alembic upgrade head to fail
with "relation llc_goals does not exist" on any fresh database.

Fix: remove the inline FK from 022, add op.create_foreign_key in 024.upgrade()
after llc_goals exists, and op.drop_constraint in 024.downgrade() before the
table is dropped. Also corrects stale docstring in 025 (still showed old
Revision ID / Revises from before the rename).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mrveiss
mrveiss merged commit c9d6345 into Dev_new_gui May 23, 2026
11 of 24 checks passed
@mrveiss
mrveiss deleted the hotfix/llc-migration-chain-v2 branch May 23, 2026 10:55
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ SSOT Configuration Compliance: Violations Found

Metric Count
Total Violations 7
SSOT Violations (high priority) 7
Other Violations 0

⚠️ 7 values have SSOT config equivalents!

These should be replaced with SSOT config imports:

Python:

from src.config.ssot_config import config
# Use: config.vm.main, config.port.backend, config.backend_url

TypeScript:

import config from '@/config/ssot-config'
// Use: config.vm.main, config.port.backend, config.backendUrl

📖 See SSOT_CONFIG_GUIDE.md for documentation.

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