30 lines
851 B
Python
30 lines
851 B
Python
import uuid
|
|
|
|
from sqlalchemy import Column, Unicode, text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from .case import Case # noqa: F401
|
|
from .meta import Base
|
|
|
|
|
|
class CaseSource(Base):
|
|
__tablename__ = "case_sources"
|
|
|
|
id = Column(
|
|
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), default=uuid.uuid4
|
|
)
|
|
name = Column("name", Unicode(255), nullable=False, unique=True)
|
|
prefix = Column("prefix", Unicode(255), nullable=False, unique=True)
|
|
|
|
cases = relationship("Case", back_populates="case_source")
|
|
|
|
def __init__(self, name=None, prefix=None, id_=None):
|
|
self.name = name
|
|
self.prefix = prefix
|
|
self.id = id_
|
|
|
|
@classmethod
|
|
def private(cls):
|
|
return uuid.UUID("08efc7cc-e4a1-4d24-bcba-58ca9bc29994")
|