改用element
增加acme多配置
This commit is contained in:
+9
-3
@@ -23,6 +23,7 @@ class Domain(Base):
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
server_id: Mapped[int] = mapped_column(Integer, ForeignKey("servers.id"), nullable=False)
|
||||
acme_config_id: Mapped[int | None] = mapped_column(Integer, ForeignKey("acme_configs.id"), nullable=True)
|
||||
domain: Mapped[str] = mapped_column(String(200), nullable=False)
|
||||
cert_dir: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
check_cmd: Mapped[str] = mapped_column(String(200), nullable=False)
|
||||
@@ -33,6 +34,7 @@ class Domain(Base):
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
server: Mapped["Server"] = relationship(back_populates="domains")
|
||||
acme_config: Mapped["AcmeConfig | None"] = relationship(back_populates="domains")
|
||||
logs: Mapped[list["DeployLog"]] = relationship(back_populates="domain")
|
||||
|
||||
|
||||
@@ -50,10 +52,11 @@ class DeployLog(Base):
|
||||
|
||||
|
||||
class AcmeConfig(Base):
|
||||
"""ACME 全局配置(单例)"""
|
||||
__tablename__ = "acme_config"
|
||||
"""ACME 配置(支持多个)"""
|
||||
__tablename__ = "acme_configs"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, default=1)
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
name: Mapped[str] = mapped_column(String(100), nullable=False, default="默认配置")
|
||||
# ACME 服务器地址
|
||||
acme_server: Mapped[str] = mapped_column(String(500), default="https://acme-v02.api.letsencrypt.org/directory")
|
||||
# 邮箱
|
||||
@@ -66,8 +69,11 @@ class AcmeConfig(Base):
|
||||
account_key: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
# 续签提前天数
|
||||
renew_days: Mapped[int] = mapped_column(Integer, default=30)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
domains: Mapped[list["Domain"]] = relationship(back_populates="acme_config")
|
||||
|
||||
|
||||
class AcmeLog(Base):
|
||||
"""ACME 操作日志"""
|
||||
|
||||
Reference in New Issue
Block a user