Repository navigation
fix(migrations): avoid duplicate Feishu delivery target columns on fresh databases - #1019
Open
fengnanrui wants to merge 1 commit into
Open
fengnanrui wants to merge 1 commit into
fengnanrui wants to merge 1 commit into
Conversation
Initial schema uses current metadata and already creates delivery_target_id on fresh databases. Inspect both tables independently before additions/removals, preserve existing values, and keep revision history unchanged. Add the owning Agent Note and schema/error/real-PostgreSQL regressions. Validated 21 related tests, focused Ruff, unchanged single Alembic head, and PostgreSQL 15/17 fresh upgrade plus downgrade/upgrade. Thirteen new regression cases failed before the fix. Staged Gitleaks and diff checks pass.
2 tasks done
This branch has not been deployed
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.
Summary
Fixes #1018.
initial_schemabuilds current ORM metadata, so empty databases already containthe Feishu
delivery_target_idcolumns. Revision f065 used to add them againunconditionally, breaking fresh installations and Drone build 588.
Inspect both tables independently and add/drop only absent/present columns.
Existing UUID values are preserved on upgrade, partial schemas are handled,
and inspection failures remain errors. No revision ID, graph edge, business
data or dependency declaration changes. A later revision cannot repair this
failure because bootstrap stops at f065; the guards must live in that revision.
The owning Agent Note documents the rationale and rollback semantics.
Verification
CLAWITH_TEST_POSTGRES_BIN=<PostgreSQL 17 bin> .venv/bin/python -m pytest tests/test_feishu_group_target_migration.py tests/test_agent_model_deleted_at_migration.py -q: 21 passed.current --check-heads, downgrade one revision and re-upgrade on PostgreSQL 15 as used by CI. Both resulting columns are nullable UUIDs.git diff --check, Gitleaks and the unchanged single Alembic head check pass.Fork checkout in the upstream Drone pipeline is separately addressed by #1015;
this PR deliberately does not duplicate that change. Once checkout is fixed,
the existing fresh-database CI stage exercises this migration repair.
The documented pre-push skill and
docs/testing.mdare absent from upstream;available checks were run directly. No production deployment was performed.
Checklist