Admin user creation moved to scripts
This commit is contained in:
@@ -31,32 +31,6 @@ async def lifespan(app: FastAPI):
|
||||
# === STARTUP ===
|
||||
app_logger = setup_logging()
|
||||
app_logger.info("Starting up ecommerce API")
|
||||
|
||||
# === REMOVED: Database table creation ===
|
||||
# Base.metadata.create_all(bind=engine) # Removed - handled by Alembic
|
||||
# create_indexes() # Removed - handled by Alembic
|
||||
|
||||
# === KEPT: Application-level initialization ===
|
||||
|
||||
# Create default admin user (after migrations have run)
|
||||
db = SessionLocal()
|
||||
try:
|
||||
auth_manager.create_default_admin_user(db)
|
||||
logger.info("Default admin user initialization completed")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to create default admin user: {e}")
|
||||
# In development, this might fail if tables don't exist yet
|
||||
# That's OK - migrations should be run separately
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
# Add any other application-level initialization here
|
||||
# Examples:
|
||||
# - Load configuration
|
||||
# - Initialize caches
|
||||
# - Set up external service connections
|
||||
# - Load initial data (AFTER migrations)
|
||||
|
||||
logger.info("[OK] Application startup completed")
|
||||
|
||||
yield
|
||||
@@ -66,13 +40,6 @@ async def lifespan(app: FastAPI):
|
||||
# Add cleanup tasks here if needed
|
||||
|
||||
|
||||
# === REMOVED FUNCTION ===
|
||||
# def create_indexes():
|
||||
# """Create database indexes."""
|
||||
# # This is now handled by Alembic migrations
|
||||
# pass
|
||||
|
||||
|
||||
# === NEW HELPER FUNCTION ===
|
||||
def check_database_ready():
|
||||
"""Check if database is ready (migrations have been run)."""
|
||||
|
||||
Reference in New Issue
Block a user