| 12345678910111213141516171819202122232425262728293031323334 |
- import enum
- from sqlalchemy import Column, Integer, String, DateTime, Boolean, Enum, Text
- from sqlalchemy.sql import func
- from app.core.database import Base
- class BackupType(str, enum.Enum):
- MANUAL = "MANUAL"
- AUTO = "AUTO"
- class BackupRecord(Base):
- __tablename__ = "backup_records"
- id = Column(Integer, primary_key=True, index=True)
- filename = Column(String(255), nullable=False)
- file_path = Column(String(512), nullable=False)
- backup_type = Column(Enum(BackupType), default=BackupType.MANUAL, nullable=False)
- created_at = Column(DateTime(timezone=True), server_default=func.now())
-
- # "users,applications,mappings"
- content_types = Column(String(255), nullable=True)
- file_size = Column(Integer, nullable=True) # Bytes
- class BackupSettings(Base):
- __tablename__ = "backup_settings"
- id = Column(Integer, primary_key=True, index=True)
- auto_backup_enabled = Column(Boolean, default=False)
- # 备份时间,例如 "02:00" (每天凌晨2点)
- backup_time = Column(String(10), default="02:00")
- # 上次自动备份时间
- last_backup_at = Column(DateTime(timezone=True), nullable=True)
-
- updated_at = Column(DateTime(timezone=True), onupdate=func.now(), server_default=func.now())
|