Files
yakpanel-core/YakPanel-server/backend/app/models/site.py

38 lines
2.1 KiB
Python
Raw Normal View History

2026-04-07 02:04:22 +05:30
"""YakPanel - Site and Domain models"""
from datetime import datetime
from sqlalchemy import String, Integer, DateTime, ForeignKey, Text
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
class Site(Base):
__tablename__ = "sites"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(128), unique=True, nullable=False, index=True)
path: Mapped[str] = mapped_column(String(512), nullable=False)
status: Mapped[int] = mapped_column(Integer, default=1) # 0=stopped, 1=running
ps: Mapped[str] = mapped_column(String(255), default="")
project_type: Mapped[str] = mapped_column(String(32), default="PHP")
php_version: Mapped[str] = mapped_column(String(16), default="74") # 74, 80, 81, 82
force_https: Mapped[int] = mapped_column(Integer, default=0) # 0=off, 1=redirect HTTP to HTTPS
2026-04-07 13:23:35 +05:30
# Reverse proxy: when proxy_upstream is non-empty, vhost uses proxy_pass instead of PHP root.
proxy_upstream: Mapped[str] = mapped_column(String(512), default="") # e.g. http://127.0.0.1:3000
proxy_websocket: Mapped[int] = mapped_column(Integer, default=0) # 1 = Upgrade headers for WS
# HTTP basic auth for a path prefix (nginx auth_basic). user_file = htpasswd path on server.
dir_auth_path: Mapped[str] = mapped_column(String(256), default="")
dir_auth_user_file: Mapped[str] = mapped_column(String(512), default="")
# Block execution of PHP under common upload paths (nginx deny).
php_deny_execute: Mapped[int] = mapped_column(Integer, default=0)
2026-04-07 02:04:22 +05:30
addtime: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
class Domain(Base):
__tablename__ = "domain"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
pid: Mapped[int] = mapped_column(Integer, ForeignKey("sites.id"), nullable=False)
name: Mapped[str] = mapped_column(String(256), nullable=False)
port: Mapped[str] = mapped_column(String(16), default="80")
addtime: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)