
- Update import from pydantic.BaseSettings to pydantic_settings.BaseSettings
- Add pydantic-settings==2.1.0 to requirements.txt for Pydantic v2 compatibility
- Implement application lifespan management for database initialization
- Add init_db.py for automatic database table creation and superuser setup
- Create test_imports.py for verifying import integrity
- Ensure proper startup sequence and error handling
This fixes the health check failure caused by Pydantic v2 migration changes.
🤖 Generated with BackendIM
Co-Authored-By: BackendIM <noreply@anthropic.com>
20 lines
693 B
Python
20 lines
693 B
Python
import os
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
PROJECT_NAME: str = "School Portal API"
|
|
VERSION: str = "1.0.0"
|
|
API_V1_STR: str = "/api/v1"
|
|
|
|
SECRET_KEY: str = os.getenv("SECRET_KEY", "your-secret-key-change-in-production")
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8 # 8 days
|
|
|
|
DATABASE_URL: str = os.getenv("DATABASE_URL", "sqlite:////app/storage/db/db.sqlite")
|
|
|
|
FIRST_SUPERUSER_EMAIL: str = os.getenv("FIRST_SUPERUSER_EMAIL", "admin@schoolportal.com")
|
|
FIRST_SUPERUSER_PASSWORD: str = os.getenv("FIRST_SUPERUSER_PASSWORD", "admin123")
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
settings = Settings() |