Skip to content

feat: Add Alembic migration scripts for DB schema changes (#596)#1063

Open
lokeshkumar69 wants to merge 4 commits into
imDarshanGK:mainfrom
lokeshkumar69:feat/db-migration-scripts
Open

feat: Add Alembic migration scripts for DB schema changes (#596)#1063
lokeshkumar69 wants to merge 4 commits into
imDarshanGK:mainfrom
lokeshkumar69:feat/db-migration-scripts

Conversation

@lokeshkumar69

Copy link
Copy Markdown

Summary

Closes #596

Implements repeatable database migration scripts using Alembic + SQLAlchemy to avoid manual schema changes and runtime failures in production.

Changes

  • backend/alembic.ini — Alembic config
  • backend/migrations/env.py — Migration environment (reads DATABASE_URL)
  • backend/migrations/script.py.mako — Template for new migrations
  • backend/app/db/models.py — SQLAlchemy ORM models (users, share_links, analyses)
  • backend/app/db/database.py — DB engine and session factory
  • backend/migrations/versions/0001_initial_schema.py — Creates all 3 tables
  • backend/migrations/versions/0002_add_user_profile_fields.py — Adds profile fields to users
  • backend/migrations/versions/0003_add_analysis_token_count.py — Adds token_count, is_public, view_count
  • .github/workflows/migration-tests.yml — CI: upgrade → downgrade → upgrade roundtrip test
  • backend/migrations/MIGRATIONS.md — Developer documentation

How to run

cd backend
pip install alembic sqlalchemy
alembic upgrade head

@imDarshanGK imDarshanGK left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add migration scripts for DB schema changes

2 participants