import Models
from app import db
from sqlalchemy.dialects.postgresql import UUID
import uuid


class JoinRequestModel(Models.Base):
    __tablename__ = 'join_request'

    id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    denied = db.Column(db.Boolean, nullable=False, default=False)
    user_id = db.Column(db.ForeignKey('user.id'))
    user = db.relationship(
        "UserModel",
        foreign_keys=user_id
    )
    project_id = db.Column(db.ForeignKey('project.id'))
    project = db.relationship(
        "ProjectModel",
        foreign_keys=project_id,
        back_populates="join_requests"
    )
