Skip to content

Restart alembic versions with the table creation #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5543f68
Pending changes for alembic
madhav165 Jul 18, 2025
9fa13f3
Merge remote-tracking branch 'origin/main' into alembic-pending
madhav165 Jul 18, 2025
2c80963
Merge remote-tracking branch 'origin/main' into alembic-pending
madhav165 Jul 21, 2025
e19963d
Merge remote-tracking branch 'origin/main' into alembic-pending
madhav165 Jul 21, 2025
c27ce28
use bootstrap_db for e2e test_db
madhav165 Jul 21, 2025
d2e8891
logging tables
madhav165 Jul 21, 2025
ecce8d6
testing
madhav165 Jul 21, 2025
08999d2
testing
madhav165 Jul 21, 2025
44f1715
testing
madhav165 Jul 21, 2025
1a47eb5
remove bootstrap_db.py
madhav165 Jul 21, 2025
9c51df1
remove bootstrap_db
madhav165 Jul 21, 2025
a035023
remove bootstrap_db in tests
madhav165 Jul 21, 2025
8edb61d
don't change test_admin_apis
madhav165 Jul 21, 2025
ec5e85e
testing tests
madhav165 Jul 21, 2025
2d2710c
test changes to tests
madhav165 Jul 21, 2025
0e3758e
testing tests
madhav165 Jul 21, 2025
6224e14
linting fixes
madhav165 Jul 21, 2025
f60fd0e
Merge remote-tracking branch 'origin/main' into alembic-pending
madhav165 Jul 22, 2025
1361cc6
Remove commented code
madhav165 Jul 22, 2025
b3035a8
Merge remote-tracking branch 'origin/main' into alembic-pending
madhav165 Jul 31, 2025
42a19cb
Run migration from docker compose
madhav165 Jul 31, 2025
38058a0
Linting fixes
madhav165 Jul 31, 2025
4629a70
Update migration in values.yaml
madhav165 Jul 31, 2025
0fe0055
Use Containerfile.lite in travis
madhav165 Jul 31, 2025
7394886
Merge remote-tracking branch 'origin/main' into alembic-pending
madhav165 Jul 31, 2025
420a2cb
isort flake and cleanup travis/compose adding back healthchecks
crivetimihai Aug 2, 2025
09f62dd
Merge branch 'main' into alembic-pending
rakdutta Aug 5, 2025
68990a0
latest from main
madhav165 Aug 11, 2025
4d56d6d
Remove bootstrap_db.py
madhav165 Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions mcpgateway/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@
from mcpgateway.config import settings
from mcpgateway.db import Base

# from mcpgateway.db import get_metadata
# target_metadata = get_metadata()


# Create config object - this is the standard way in Alembic
config = getattr(context, "config", None) or Config()

Expand Down Expand Up @@ -111,18 +107,9 @@ def _inside_alembic() -> bool:
disable_existing_loggers=False,
)

# First-Party
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel

target_metadata = Base.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.

config.set_main_option(
"sqlalchemy.url",
settings.database_url,
Expand Down
2 changes: 1 addition & 1 deletion mcpgateway/bootstrap_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ async def main() -> None:

if "gateways" not in insp.get_table_names():
logger.info("Empty DB detected - creating baseline schema")
Base.metadata.create_all(bind=conn)
command.stamp(cfg, "head")
Base.metadata.create_all(bind=conn)
else:
command.upgrade(cfg, "head")

Expand Down
10 changes: 1 addition & 9 deletions mcpgateway/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@
# Wait for database to be ready before creating tables
wait_for_db_ready(max_tries=int(settings.db_max_retries), interval=int(settings.db_retry_interval_ms) / 1000, sync=True) # Converting ms to s

# Create database tables
try:
loop = asyncio.get_running_loop()
except RuntimeError:
asyncio.run(bootstrap_db())
else:
loop.create_task(bootstrap_db())


# Initialize services
tool_service = ToolService()
resource_service = ResourceService()
Expand Down Expand Up @@ -209,6 +200,7 @@ async def lifespan(_app: FastAPI) -> AsyncIterator[None]:
"""
logger.info("Starting MCP Gateway services")
try:
await bootstrap_db()
await tool_service.initialize()
await resource_service.initialize()
await prompt_service.initialize()
Expand Down
Loading