File size: 1,535 Bytes
021e065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from sqlalchemy import (
  Column, String, Boolean, DateTime, Integer,
  Float, Text, Date, Index
)
from sqlalchemy.sql import func
from .base import Base

class Project(Base):
  __tablename__ = "projects"
  
  id = Column(Integer, primary_key=True)
  project_id = Column(String(36), unique=True, nullable=False, index=True)
  user_hash = Column(String(64), nullable=False, index=True)
  tenant_id = Column(String(64), nullable=True, index=True)
  
  title = Column(String(200), nullable=False)
  objective = Column(Text)
  project_type = Column(String(30))
  # savings | debt | tax | payroll | budget | compliance | other
  
  status = Column(String(20), default="active")
  # active | paused | completed | cancelled
  
  # Financial targets
  target_amount = Column(Float)
  current_amount = Column(Float, default=0)
  target_date = Column(Date)
  
  # Living summary
  summary = Column(Text)
  open_questions = Column(Text, default="[]")
  key_decisions = Column(Text, default="[]")
  next_action = Column(Text)
  
  # Linked items
  linked_files = Column(Text, default="[]")
  linked_chat_sessions = Column(Text, default="[]")
  
  # Timestamps
  created_at = Column(DateTime, server_default=func.now())
  updated_at = Column(DateTime, onupdate=func.now())
  last_active = Column(DateTime, server_default=func.now())
  
  __table_args__ = (
    Index("ix_projects_user", "user_hash"),
    Index("ix_projects_status", "status"),
    Index("ix_projects_tenant", "tenant_id"),
    Index("ix_projects_last_active", "last_active"),
  )