cleanup(phase7): regenerate migrations to post-phase-7 initial#1666
Merged
Conversation
Replace the 32-revision Alembic chain with a single post-Phase-7 initial migration. Fresh empty DB → `alembic upgrade head` now yields the exact same schema as the current ORM state, with no intermediate LightRAG / legacy steps. Ghost-check: - docs/modularization/cleanup-inventory.md §Phase7-postmerge: chain collapsed, zero schema change - §1 Layer A / B / C untouched: aperag/db/base.py Base.metadata unchanged; aperag/db/models.py Invitation class-body `Role` binding via `from aperag.domains.identity.db.models import ... Role ...` preserved; env.py per-domain model imports preserved - G17 / G18-alt CRITICAL_WIRINGS unchanged (migration layer doesn't touch DI); 20/20 G1-G19 boundary tests pass Verification: - Old chain: 32 revisions (base db9c88848f52 → head e1f2a3b4c5d6) - New chain: 1 revision (base → head 6a8fc31427d9 `post_phase_7_initial`) - Round-trip: `alembic downgrade base` + `alembic upgrade head` succeed against fresh local Postgres 16 + pgvector 0.7.2 DB; 41 relations created (40 ORM tables + alembic_version) - Stability: second `alembic revision --autogenerate` produces an empty upgrade() / downgrade() (no drift) - Tables: all 13 domain surfaces present (identity / governance / model_platform / marketplace / knowledge_base / indexing / retrieval / knowledge_graph / conversation / agent_runtime / evaluation) plus 11 legacy local ORMs (ConfigModel / UserQuota / Invitation / PromptTemplate / Setting / ExportTask / Evaluation / EvaluationItem / Question / QuestionSet / ModelServiceProvider) - No pgvector extension / Vector column DDL in the initial: no ORM declares Vector type post-Phase-7 (LightRAG tables already dropped) - No re-export shim leakage; invitation.role renders as String(50) (EnumColumn helper is a varchar, matching identity domain Role) Tests: - tests/unit_test/test_modularization_boundaries.py: 20 passed - tests/unit_test/ broad regression (minus pre-existing unrelated failure `test_phase1_fe_complete_identity_auth_admin_audit_adapter_boundary`): 577 passed, 29 skipped Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Weston blocker-level CR (msg=fa0b6b4e) found 1 mechanical `git diff --check` blocker: `aperag/migration/versions/20260425041904-6a8fc31427d9.py:4` had trailing whitespace on the `Revises: ` line (template artifact from alembic autogenerate). Normalized via `rstrip()` on all lines. Whitespace-only change; no logic or schema diff. Ghost-check: none — §1 Layer A/B/C/D/E untouched; whitespace-only trailing-space strip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 7 收尾:全量数据库 migration 重生 — task #33
Per 主架构师 @符炫炜 canonical 边界(task #33 thread msg=4d8a6c49) + PM msg=caffbd22 执行口径。
Baseline
origin/main @ 613514c4(Phase 7 post-cleanup code terminal state)db9c88848f52→ heade1f2a3b4c5d6)6a8fc31427d9post_phase_7_initial,down_revision = None)Scope (minimal canonical work only — per symofons gate)
仅重生
aperag/migration/versions/*.py反映 post-Phase-7 ORM state;不做 schema 变更 / domain absorption / ORM drift 修补。Execution summary
20260425041904-6a8fc31427d9_post_phase_7_initial.py(865 lines)op.create_table()calls — all expected, no driftInspect results
29 domain ORM tables(all 12 domains covered):
user/oauth_accountapi_key/audit_logllm_provider/llm_provider_modelscollection_marketplace/user_collection_subscriptioncollection/document/collection_summarydocument_indexsearchhistorygraphindex_nodes/graphindex_edges/graphindex_chunks/graph_curation_runs/graph_curation_suggestionsbot/chat/turn_feedbackagent_turn/agent_timeline_event/agent_artifactevaluation_datasets/evaluation_dataset_items/evaluation_runs/evaluation_run_items/evaluation_run_item_attempts11 legacy local ORMs (still in
aperag/db/models.pyper inventory v1 §1 Layer C + Phase 7 end-state legacy compatibility layer):config/user_quota/invitation/prompt_template/setting/export_task/evaluations/evaluation_items/questions/question_sets/model_service_provider§1 PERMANENT verification
invitation.rolecolumn →sa.String(length=50)(viaEnumColumnhelper producingString(max_enum_value_length)peraperag/db/models.py:55-59) — identity-domainRoleenum binding preserved, class-body load-time import intact ✅aperag/db/base.pyBase.metadata— unchanged ✅aperag/migration/env.pyper-domain model imports — unchanged ✅pgvector observation (informational, not drift)
No
Vector()columns in the new initial migration. Post-Phase-7Base.metadatahas zero ORM tables declaring aVectorcolumn (LightRAG tables were dropped earlier in Phase 7 chain). The pgvector extension creation was removed with them. This matches current ORM state — not drift. If the pgvector module (outsideBase.metadata) provisions its own schema at runtime, it would create its own extension. Flagged for task #34 smoke verification.Round-trip + stability gates
127.0.0.1:55432/aperag)alembic downgrade base→ success (no-op on empty DB, chain traversable)alembic upgrade head→ success exit 0, 41 relations created (40 tables +alembic_version)alembic revision --autogenerate -m "_tmp_verify_no_diff"→upgrade() pass/downgrade() passempty — zero drift ✅(终态稳定)G-gate results
pytest tests/unit_test/test_modularization_boundaries.py -x -q→ 20 passed / 0 failed (G1-G19 all green) ✅pytest tests/unit_test/ -x --ignore=tests/unit_test/objectstore -q→ 577 passed / 29 skipped / 1 failed — the single failure (test_web_typed_api_contract.py::test_phase1_fe_complete_identity_auth_admin_audit_adapter_boundarymissinglistUserQuotas) is pre-existing on baseline613514c4(verified by stash+rerun); unrelated to migration regen. This is a FE contract drift on main, flagged separately.Ghost-check
Ghost-check: none — §1 Layer A/B/C/D/E untouched; scope strictly bounded to
aperag/migration/versions/*.pyreplacement; 32 old migrations deleted, 1post_phase_7_initialcreated; round-trip + no-diff verified on real local Postgres + pgvector.Follow-up
用户本地部署 + 冒烟验证— pgvector extension provisioning should be verified in task collect the API metrics and logs of KubeChat and show them in the Grafana dashboard #34 smoke test. If runtime needs extension, a small migration can addCREATE EXTENSION vectoras fix-forward.per
docs/modularization/cleanup-inventory.mdv1 §Phase7-postmerge + 符炫炜 task-thread canonical gate.🤖 Generated with Claude Code