Refactor investor-related schemas and models; update database configuration and enhance investor processing logic

This commit is contained in:
bolade
2025-09-02 15:51:35 +01:00
parent 65b5df3a43
commit 7b58834316
15 changed files with 258 additions and 51 deletions
+18 -4
View File
@@ -33,6 +33,8 @@ investor_sector_association = Table(
Column("investor_id", Integer, ForeignKey("investors.id")),
Column("sector_id", Integer, ForeignKey("sectors.id")),
)
class InvestorTable(Base):
__tablename__ = "investors"
@@ -42,7 +44,7 @@ class InvestorTable(Base):
aum = Column(Integer, nullable=False) # Assets Under Management
check_size_lower = Column(Integer, nullable=False) # Lower bound
check_size_upper = Column(Integer, nullable=False) # Upper bound
geography = Column(String, nullable=False)
geographic_focus = Column(String, nullable=False)
stage_focus = Column(Enum(InvestmentStage), nullable=False)
number_of_investments = Column(Integer, default=0)
created_at = Column(DateTime, default=datetime.datetime.now(datetime.UTC))
@@ -58,6 +60,12 @@ class InvestorTable(Base):
secondary=investor_company_association,
back_populates="investors",
)
team_members = relationship("InvestorTeamMember", back_populates="investor")
sectors = relationship(
"SectorTable",
secondary=investor_sector_association,
back_populates="investors",
)
class CompanyTable(Base):
@@ -88,16 +96,22 @@ class SectorTable(Base):
__tablename__ = "sectors"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, unique=True, nullable=False)
name = Column(String, nullable=False)
# Add relationship back to investors
investors = relationship(
"InvestorTable",
secondary=investor_sector_association,
back_populates="sectors",
)
class InvestorTeamMember(Base):
__tablename__ = "investor_team"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False)
role = Column(String, nullable=False)
email = Column(String, unique=True, nullable=False)
email = Column(String, nullable=False)
investor_id = Column(Integer, ForeignKey("investors.id"))
investor = relationship("InvestorTable", back_populates="team_members")