SpectralVPN/API/models/server.py
2026-04-16 00:07:48 +03:00

18 lines
1,013 B
Python

from datetime import datetime
from sqlalchemy import String, DateTime
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy.sql import func
from .base import Base
class Server(Base):
__tablename__ = "servers"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(64), nullable=False, unique=True)
code: Mapped[str] = mapped_column(String(128), nullable=False, unique=True, index=True)
host: Mapped[str] = mapped_column(String(128), nullable=False, unique=True)
port: Mapped[int] = mapped_column(nullable=False)
user: Mapped[str] = mapped_column(String(64), nullable=False)
password: Mapped[str] = mapped_column(String(64), nullable=False)
inbound_id: Mapped[int] = mapped_column(nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), nullable=False)
deleted_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)