Initial commit
This commit is contained in:
25
backend/app/models/settings.py
Normal file
25
backend/app/models/settings.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user