Skip to content

[AUDIT-007] Reconcile SQL models with migration files (schema drift) #2169

Open

Description

@groupthinking

[AUDIT-007] SQL Models Exceed Migration Coverage (🟠 HIGH)

Title: Reconcile SQL models with migration files (schema drift)

Description:
Rich SQL model surface (120+ lines of mixins in base.py) but only 3 migration files visible:

  • migrations/versions/001_...
  • migrations/versions/002_...
  • migrations/versions/003_...

Impact: Schema drift risk, unclear state ownership, silent migrations

Files to Review:

  • src/youtube_extension/backend/models/base.py (model mixins)
  • src/youtube_extension/backend/migrations/versions/ (only 3 files?)
  • src/youtube_extension/backend/config/database.py (RLS config unclear)
  • All model files under src/youtube_extension/backend/models/

Required Actions:

  1. Inventory all active SQL models
  2. Map models to migration coverage
  3. Identify unmigrated models (schema drift risk)
  4. Create missing migrations or deprecate models
  5. Document RLS and tenanting strategy

Acceptance Criteria:

  • All active models have migration history
  • No schema drift (model ≠ database)
  • RLS and tenanting strategy documented
  • Migration file naming consistent

Labels: 🟠 high, database, backend, migrations

Related: .github/AUDIT_FINDINGS_SESSION.md Section 7



Audit master doc: .github/AUDIT_FINDINGS_SESSION.md
Source session: https://github.com/groupthinking/EventRelay/tasks/36f6c3e5-60dc-4dfe-a151-ef2ab9114afa
Remediation phase: Phase 3: Medium (Month 2)

Cross-links: Previous: #2168 | Next: #2170 | Audit index: #2163

Activity

  1. linear-code commented on Sep 20, 2026

    @linear-code
    Contributor
  2. github-actions commented on Sep 20, 2026

    @github-actions
    Contributor

    👋 Thanks for opening this issue! It has been automatically labeled for triage.

  3. groupthinking commented on Sep 20, 2026

    @groupthinking
    OwnerAuthor

    Tracker: #2175

  4. groupthinking commented on Sep 21, 2026

    @groupthinking
    OwnerAuthor

    Verification review — reopened

    Commit bb06a041 documents the current migration gap, but docs/MIGRATION_TRUTH.md explicitly queues incremental migrations after inventory sign-off.

    The added guard only asserts that at least three migration files and five model modules exist. It does not map active models to revisions, compare model/database shape, identify unmigrated domains, or verify RLS/tenanting.

    Remaining evidence required:

    • an explicit active-model → migration/revision matrix;
    • classification of optional/non-production model domains;
    • missing additive migrations or documented deprecations;
    • RLS and tenant-boundary evidence; and
    • a drift test that fails on an unmapped production model or column, not merely on low file counts.

    The inventory document and guard are useful partial work. The issue is reopened because its stated acceptance criteria are not yet demonstrated.

  5. kk-agent commented on Sep 28, 2026

    @kk-agent
    Collaborator

    Max-aggressive cleanup 2026-09-28: EventRelay/UVAI product work is PARKED. Closing this stale/open item. Reopen if Hayden unparks the cut.

  6. groupthinking commented on Oct 8, 2026

    @groupthinking
    OwnerAuthor

    Reopened; current source tree disproves the old three-revision inventory. PR #2378 corrects MIGRATION_TRUTH.md and preserves the historical claim. No legacy backend model/migration directory or claimed unit guard exists in inspected current main; alembic.ini remains dangling, while one Supabase SQL migration exists. BLOCKED for complete reconciliation: identify active database/owning service and obtain approved read-only deployed revision/RLS evidence; decide whether legacy Alembic config is retired or restored. No migration was generated/applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions