Add database-backed configuration (AppSetting model, ConfigService, settings API)
- Add AppSetting model for key-value settings storage in PostgreSQL - Create ConfigService with DB-first, env-var-fallback resolution - Add admin-only /api/v1/settings CRUD endpoints - Update tasks.py to use ConfigService for SMTP config - Seed default settings on application startup - Add 24 unit tests for ConfigService (all passing) Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/ce88d4a8-d8c2-49b3-95a1-30592105a769
This commit is contained in:
@@ -430,3 +430,30 @@ class GmailCredential(Base):
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", backref="gmail_credential")
|
||||
|
||||
|
||||
class AppSetting(Base):
|
||||
"""
|
||||
Application settings stored in the database.
|
||||
|
||||
Provides database-backed configuration that supplements or overrides
|
||||
environment variable settings. Bootstrap settings (DATABASE_URL,
|
||||
SECRET_KEY, ENCRYPTION_KEY) must still come from environment variables,
|
||||
but all other settings can be managed via the database.
|
||||
"""
|
||||
|
||||
__tablename__ = "app_settings"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
key = Column(String(255), unique=True, nullable=False, index=True)
|
||||
value = Column(Text, nullable=True)
|
||||
value_type = Column(String(50), default="string") # string, int, float, bool, json
|
||||
description = Column(Text, nullable=True)
|
||||
is_secret = Column(Boolean, default=False)
|
||||
category = Column(String(100), nullable=True, index=True)
|
||||
|
||||
# Timestamps
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at = Column(
|
||||
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user