Skip to content

hotfix(migrations): fix duplicate LLC Alembic revision IDs (20260523_022) - #8460

Closed
mrveiss wants to merge 2 commits into
Dev_new_guifrom
hotfix/llc-migration-chain
Closed

mrveiss wants to merge 2 commits into
Dev_new_guifrom
hotfix/llc-migration-chain

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:

  • 20260523_022_create_llc_work_items.py (GH#8213, merged 08:56Z)
  • 20260523_022_organization_llc_extensions.py (GH#8211, merged 09:33Z) ← DUPLICATE
  • 20260523_022_llc_goals.py (GH#8212, merged 09:41Z) ← DUPLICATE

Fix

Creates a linear chain:

021 → 022 (work_items) → 023 (org_extensions) → 024 (goals)

Files renamed and revision/down_revision updated accordingly.

Impact on pending PRs

All pending LLC migration PRs must update to use revision >= 025 with down_revision = "20260523_024":

🤖 Generated with Claude Code

…022)

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

  021 (heartbeat_wakeup) → 022 (create_llc_work_items) [unchanged]
  → 023 (organization_llc_extensions)  [renamed from 022]
  → 024 (llc_goals)                    [renamed from 022]

All pending LLC PRs must rebase and use revision 025+ with down_revision = 024.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@github-actions

github-actions Bot commented May 23, 2026 •

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.

The previous commit put create_llc_work_items at 022 and llc_goals at 024,
but create_llc_work_items has sa.ForeignKey("llc_goals.id") — PostgreSQL
requires the referenced table to exist at CREATE TABLE time, so that order
would fail with "relation llc_goals does not exist".

Correct linear chain (respects FK dependencies):
  021 (heartbeat_wakeup)            — existing anchor
  022 (llc_goals)                   — no FK deps, must come first
  023 (organization_llc_extensions) — no FK deps on LLC tables
  024 (create_llc_work_items)       — FK to llc_goals.id, must come last

Head is still 024; downstream PRs (#8457, #8458, #8459) still need
down_revision = "20260523_024".

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

mrveiss commented May 23, 2026

Copy link
Copy Markdown
Owner Author

Fix updated: corrected FK dependency ordering

The initial commit had create_llc_work_items at revision 022 and llc_goals at 024. This would still break because create_llc_work_items has sa.ForeignKey("llc_goals.id") — PostgreSQL requires the referenced table to exist at CREATE TABLE time.

Final correct chain:

021 (heartbeat_wakeup_merged_count)  ← existing anchor
022 (llc_goals)                      ← no FK deps; must run first
023 (organization_llc_extensions)    ← standalone column additions
024 (create_llc_work_items)          ← FK to llc_goals.id; runs after 022

Head is still 024 — downstream PRs (#8457, #8458, #8459) still need down_revision = "20260523_024" as specified in MVA-868.

@mrveiss

mrveiss commented May 23, 2026

Copy link
Copy Markdown
Owner Author

Superseded by hotfix/llc-migration-chain-v2 — PR #8460 conflicts with Dev_new_gui because commit 6091fb4a5 (feat(llc): per-agent budget enforcement, GH#8215) landed after this PR was opened and introduced 025_llc_agent_budgets.py with down_revision = '20260523_022'. The v2 branch resolves all issues: same duplicate-ID fix (022→023/024 renaming), plus deferred FK (fk_llc_work_items_goal_id) wired correctly in 024_llc_goals.py, and the budget migration chained to 025 with down_revision = '20260523_024'. New PR opened from v2 instead.

mrveiss added a commit that referenced this pull request May 23, 2026
…H#8216)

Implements GH#8216: append-only LLC activity log with company scoping, all-mutation coverage, and Redis pub/sub fanout.

- LLCActivityLog model (LLCBase, organizations FK, 6 composite indexes)
- LLCActivityLogService: record(), record_bulk(), query() with pagination; _publish() failures non-fatal, tz-normalized date filters, UUID-validated inputs
- GET /api/llc/companies/{id}/activity — auth-gated via get_current_user
- Migration 20260523_026 chained after 20260523_025
- 16 unit tests covering actor routing, append-only contract, Redis channel/payload, pagination guards

CR: MVA-864 — 9 CR findings addressed (MVA-866) + migration chain via PR #8460/MVA-873

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@mrveiss
mrveiss deleted the hotfix/llc-migration-chain branch May 27, 2026 18:44
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