26 lines
879 B
Python
26 lines
879 B
Python
"""Settings model for application configuration."""
|
|
|
|
from sqlalchemy import Column, String, Boolean, Integer, DateTime
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Settings(Base):
|
|
"""Settings model for storing application-wide configuration."""
|
|
|
|
__tablename__ = "settings"
|
|
|
|
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
|
key = Column(String, unique=True, index=True, nullable=False)
|
|
value_bool = Column(Boolean, nullable=True)
|
|
value_str = Column(String, nullable=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
|
|
def get_value(self):
|
|
"""Get the actual value (bool or string)."""
|
|
if self.value_bool is not None:
|
|
return bool(self.value_bool)
|
|
return self.value_str
|