ipns-eval-poc-backend / src /models /_comparitive_weights.py
Aryan Jain
update table schema
5cb75d9
from enum import Enum as PyEnum
from sqlalchemy import (
Boolean,
Column,
DateTime,
Enum,
Float,
ForeignKey,
Integer,
String,
func,
)
from sqlalchemy.dialects.postgresql import UUID
from pydantic import BaseModel
from ._base import Base
class Weights(PyEnum):
NONE = "NONE"
LOW = "LOW"
MEDIUM = "MEDIUM"
HIGH = "HIGH"
class ComparativeWeights(Base):
__tablename__ = "comparative_weights"
id = Column(UUID(as_uuid=True), primary_key=True, nullable=False)
rfp_id = Column(
UUID(as_uuid=True),
ForeignKey("rfps.id", ondelete="CASCADE"),
nullable=False,
unique=True,
)
technical_weight = Column(Enum(Weights, name="comparativeweights"), nullable=False)
management_weight = Column(Enum(Weights, name="comparativeweights"), nullable=False)
past_performance_weight = Column(
Enum(Weights, name="comparativeweights"), nullable=False
)
price_weight = Column(Enum(Weights, name="comparativeweights"), nullable=False)
strengths_weight = Column(Float, nullable=False, default=15)
weaknesses_weight = Column(Float, nullable=False, default=5)
flag = Column(Boolean(), nullable=True, default=False)
created_at = Column(DateTime, nullable=False, default=func.now())
updated_at = Column(
DateTime, nullable=False, default=func.now(), onupdate=func.now()
)