35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
import uuid
|
|
|
|
from .database import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
name = Column(String, index=True)
|
|
username = Column(String(length=24), unique=True, index=True)
|
|
hashed_password = Column(String)
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
owns_queues = relationship("Queue", backref="owner", lazy="dynamic")
|
|
|
|
|
|
class AnonymousUser(Base):
|
|
__tablename__ = "anonymoususers"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
name = Column(String, index=True)
|
|
|
|
|
|
class Queue(Base):
|
|
__tablename__ = "queues"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
name = Column(String, index=True)
|
|
description = Column(String, index=True)
|
|
owner_id = Column(UUID(as_uuid=True), ForeignKey("users.id"))
|