Add improvements
This commit is contained in:
@@ -17,11 +17,6 @@ class TenantService(StandardFastAPIService):
|
||||
|
||||
expected_migration_version = "00001"
|
||||
|
||||
async def on_startup(self, app):
|
||||
"""Custom startup logic including migration verification"""
|
||||
await self.verify_migrations()
|
||||
await super().on_startup(app)
|
||||
|
||||
async def verify_migrations(self):
|
||||
"""Verify database schema matches the latest migrations."""
|
||||
try:
|
||||
@@ -67,6 +62,9 @@ class TenantService(StandardFastAPIService):
|
||||
|
||||
async def on_startup(self, app: FastAPI):
|
||||
"""Custom startup logic for tenant service"""
|
||||
# Verify migrations first
|
||||
await self.verify_migrations()
|
||||
|
||||
# Import models to ensure they're registered with SQLAlchemy
|
||||
from app.models.tenants import Tenant, TenantMember, Subscription
|
||||
from app.models.tenant_settings import TenantSettings
|
||||
@@ -87,6 +85,11 @@ class TenantService(StandardFastAPIService):
|
||||
await start_scheduler(self.database_manager, redis_client, settings)
|
||||
self.logger.info("Usage tracking scheduler started")
|
||||
|
||||
# Run startup seeders (pilot coupon, etc.)
|
||||
from app.jobs.startup_seeder import run_startup_seeders
|
||||
await run_startup_seeders(self.database_manager)
|
||||
self.logger.info("Startup seeders completed")
|
||||
|
||||
async def on_shutdown(self, app: FastAPI):
|
||||
"""Custom shutdown logic for tenant service"""
|
||||
# Stop usage tracking scheduler
|
||||
|
||||
Reference in New Issue
Block a user