Skip to content
Snippets Groups Projects
models.py 1.34 KiB
Newer Older
Pierre Chanial's avatar
Pierre Chanial committed
"""The object-relational mapping for the ESAP-DB admin database."""
from sqlalchemy import BigInteger, Boolean, Column, ForeignKey, Integer, String
from sqlalchemy.orm import declarative_base

Base = declarative_base()


class DBProjectServer(Base):
    """The model representing an ESAP-DB database server to store the projects."""

    __tablename__ = 'project_servers'
    id = Column(Integer, primary_key=True, index=True)
    uri = Column(String, unique=True, nullable=False)
    max_size = Column(BigInteger, nullable=False)
    available_size = Column(BigInteger, nullable=False)


class DBProject(Base):
    """The model representing an ESAP-DB project."""

    __tablename__ = 'projects'
    id = Column(Integer, primary_key=True, index=True)
    project_server_id = Column(Integer, ForeignKey('project_servers.id'))
    name = Column(String(256), index=True, nullable=False)
    description = Column(String, nullable=False)
    uri = Column(String, nullable=False)
    max_size = Column(BigInteger, nullable=False)


class DBUser(Base):
    """The model representing an ESAP-DB user."""

    __tablename__ = 'users'
    id = Column(Integer, primary_key=True, index=True)
    first_name = Column(String, nullable=False)
    last_name = Column(String, nullable=False)
    email = Column(String, nullable=False)
    is_superuser = Column(Boolean, nullable=False)