initial commit

This commit is contained in:
2025-06-03 14:01:08 +00:00
commit 6ab9ceed4b
50 changed files with 2253 additions and 0 deletions

28
server/models.py Normal file
View File

@@ -0,0 +1,28 @@
from sqlalchemy import Column, Integer, String, Enum, TIMESTAMP, func
from sqlalchemy.orm import declarative_base
import enum
Base = declarative_base()
class UserRole(enum.Enum):
user = "user"
admin = "admin"
superadmin = "superadmin"
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True, autoincrement=True)
username = Column(String(50), unique=True, nullable=False)
password_hash = Column(String(60), nullable=False)
role = Column(Enum(UserRole), nullable=False, default=UserRole.user)
created_at = Column(TIMESTAMP, server_default=func.current_timestamp())
updated_at = Column(TIMESTAMP, server_default=func.current_timestamp(), onupdate=func.current_timestamp())
class Client(Base):
__tablename__ = 'clients'
uuid = Column(String(36), primary_key=True, nullable=False)
hardware_hash = Column(String(64), nullable=False)
location = Column(String(100), nullable=True)
ip_address = Column(String(45), nullable=True)
registration_time = Column(TIMESTAMP, server_default=func.current_timestamp(), nullable=False)
last_alive = Column(TIMESTAMP, server_default=func.current_timestamp(), onupdate=func.current_timestamp(), nullable=False)