Skip to content

Conversation

@crivetimihai
Copy link
Member

@crivetimihai crivetimihai commented Jun 26, 2025

🛢️ Add Alembic for Database Migrations

This PR introduces Alembic to manage schema migrations for the mcpgateway database to support #151 and #176 - as well as future database schema changes and migrations. See ./alembic/README.md in this PR.

✅ Highlights

  • Added Alembic scaffolding (alembic.ini, alembic/env.py, script.py.mako, versions/)
  • Integrated with existing SQLAlchemy models (Base.metadata)
  • Supports autogeneration based on model diffs
  • Included Makefile targets for common migration tasks

🧪 Usage

Create a migration:

make db-new MSG="add users table"

Apply migrations:

make db-up

Rollback one revision:

make db-down

Inspect state:

make db-current      # Show applied revision
make db-history      # Show full revision tree

🧠 Notes

  • Migrations are stored in alembic/versions/.
  • The DB URL is read dynamically from settings.database_url.
  • All models must be properly imported for autogeneration to detect changes.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai merged commit 2eb8af8 into main Jun 27, 2025
16 of 19 checks passed
@crivetimihai crivetimihai deleted the alembic-scaffolding-test branch June 27, 2025 06:50
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
Add alembic initial setup

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 16, 2025
Add alembic initial setup
Signed-off-by: Vicky Kuo <vicky.kuo@ibm.com>
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.

2 participants