fix(deploy-tradein): track SQL migrations with _schema_migrations + baseline #637
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#637
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/tradein-migration-tracking"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes H1 — the root cause of the 2026-05-28 verification-debt incident («не знаем, наложились ли миграции»).
deploy-tradein.ymlapplied migrations withpsql ... < file || echo "(skipped — already applied or error)":.sqlre-ran on every deploy.Ports the proven
_schema_migrationspattern from the maindeploy.yml(skip-if-applied +|| { echo FAILED; exit 1; }), adapted for-p gendesign-tradein/psql -U tradein -d tradein/backend/data/sql/. Adds a first-run baseline: when the tracking table doesn't pre-exist, all current filenames are seeded as already-applied WITHOUT running them — prod is live on 001-076 and 7 of those carry non-idempotent INSERT seeds (002/003/052/053/054/063/072) that would PK-violate under the new strict gate.Reviewed by code-reviewer: ✅ approve, no blockers (port is faithful; the added
tr -dtrim makes it more robust than the reference against trailing CR fromexec -T).Caveat (documented)
The first deploy seeds 001-076 as baseline (not executed). Do not bundle a brand-new migration in the very same push that introduces
_schema_migrations— it would be marked applied without running. This PR ships zero.sql, so the condition is already satisfied; once tracking exists the baseline never re-fires.Test plan
yaml.safe_load)set -euo pipefail: baseline path / steady-state new-migration / failing-migration →exit 1up -d→ migrate →restart tradein-backend(FDW hook, PR #493)✓ Already appliedfor 001-076; then qa-tester smoke on tradein routesCloses #636