Spaces:
Running
Running
Commit ·
0bfa193
1
Parent(s): 3b3d5cb
Add Family expenses table
Browse files- app/db/models.py +2 -1
- app/db/models_family.py +25 -0
app/db/models.py
CHANGED
|
@@ -23,7 +23,8 @@ class UserDB(Base):
|
|
| 23 |
otp_code = Column(String(6), nullable=True)
|
| 24 |
otp_expiry = Column(DateTime, nullable=True)
|
| 25 |
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
| 26 |
-
|
|
|
|
| 27 |
# class PostDB(Base):
|
| 28 |
# __tablename__ = "posts"
|
| 29 |
# id = Column(Integer, primary_key=True, index=True)
|
|
|
|
| 23 |
otp_code = Column(String(6), nullable=True)
|
| 24 |
otp_expiry = Column(DateTime, nullable=True)
|
| 25 |
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
| 26 |
+
family = relationship("Family", back_populates="head", uselist=False)
|
| 27 |
+
|
| 28 |
# class PostDB(Base):
|
| 29 |
# __tablename__ = "posts"
|
| 30 |
# id = Column(Integer, primary_key=True, index=True)
|
app/db/models_family.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey
|
| 2 |
+
from sqlalchemy.orm import relationship
|
| 3 |
+
from sqlalchemy.sql import func
|
| 4 |
+
from app.db.database import Base
|
| 5 |
+
|
| 6 |
+
class Family(Base):
|
| 7 |
+
__tablename__ = "families"
|
| 8 |
+
|
| 9 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 10 |
+
family_code = Column(String(10), unique=True, index=True, nullable=False)
|
| 11 |
+
|
| 12 |
+
head_id = Column(Integer, ForeignKey("user_accounts.id"), nullable=False)
|
| 13 |
+
|
| 14 |
+
# Financial info (added during onboarding step 2)
|
| 15 |
+
total_balance = Column(Float, default=0.0)
|
| 16 |
+
total_income = Column(Float, default=0.0)
|
| 17 |
+
|
| 18 |
+
# Expected members (comma separated or JSON)
|
| 19 |
+
# For now keep as TEXT for flexibility
|
| 20 |
+
expected_members = Column(String, nullable=True)
|
| 21 |
+
|
| 22 |
+
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
| 23 |
+
|
| 24 |
+
# Relationships
|
| 25 |
+
head = relationship("UserDB", back_populates="family")
|