Skip to content

fix: remove dead migration SQL that references nonexistent tables (issue #1877) - #1911

Merged
komalharshita merged 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1877-migrations-dangling-fk
Aug 16, 2026
Merged

fix: remove dead migration SQL that references nonexistent tables (issue #1877)#1911
komalharshita merged 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1877-migrations-dangling-fk

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Problem

The migrations/ directory is disconnected from the application's real schema. Its SQL files reference tables (paths, certificates, discussion_threads, thread_comments, bookmarks, user_topic_progress, user_activity) that no SQLAlchemy model defines, and 001/002 declare FOREIGN KEY ... REFERENCES paths(id) against a paths table that does not exist anywhere — learning paths are stored in-memory. There is also no migration runner (no Alembic/Flask-Migrate config, no code reads the .sql files), so none of the files can be applied in any supported workflow. The app creates its schema with db.create_all() from src/models.py (src/app.py, src/seed_db.py).

Fix

  • Removed the five unapplied, schema-drifted SQL files from migrations/.
  • Documented the intended data model in migrations/README.md: the schema is defined exclusively by src/models.py (projects, users, project_progress, user_game_progress) and created via db.create_all(); no paths table exists.
  • Added tests/test_db_schema_consistency.py — a pure-file CI check that (1) every db.ForeignKey(...) in src/models.py targets a defined table, and (2) any SQL migration in migrations/ may only reference model tables or tables created by an earlier migration in the set, so a dangling FK like REFERENCES paths(id) can never be reintroduced.

Files changed

  • migrations/001_create_certificates_table.sql — deleted
  • migrations/002_create_discussion_tables.sql — deleted
  • migrations/003_create_bookmarks_table.sql — deleted
  • migrations/004_create_progress_tables.sql — deleted
  • migrations/005_create_user_game_progress.sql — deleted
  • migrations/README.md — documents the model-driven schema
  • tests/test_db_schema_consistency.py — new consistency/regression check

Testing

Closes #1877

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@ionfwsrijan is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

@komalharshita
komalharshita merged commit 4afe826 into komalharshita:main Aug 16, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: migrations directory references tables that no model defines - dangling FK to nonexistent paths(id), no runner

2 participants