-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.py
More file actions
59 lines (44 loc) · 2.31 KB
/
models.py
File metadata and controls
59 lines (44 loc) · 2.31 KB
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
51
52
53
54
55
56
57
58
59
from datetime import datetime
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from database import Base
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True)
# Phone number from Twilio "From" field (e.g., "+14045551234")
phone_number = Column(String(50), unique=True, nullable=False, index=True)
# New: full name that user types once during onboarding
full_name = Column(String(255), nullable=True)
# Emory email typed by user via SMS, must end with @emory.edu (enforced in code)
emory_email = Column(String(255), unique=True, nullable=True)
# True once they successfully enter the correct code from their Emory email
is_verified = Column(Boolean, nullable=False, default=False)
# Temporary 6-digit code we email them; cleared (set to NULL) after success
otp_code = Column(String(6), nullable=True)
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
# Relationship to ride requests (optional for now, but useful later)
rides = relationship("Rides", back_populates="user")
class Rides(Base):
__tablename__ = "rides"
id = Column(Integer, primary_key=True, index=True)
# FK link to user
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
user = relationship("User", back_populates="rides")
# Original text the user sent
original_message = Column(String(500), nullable=False)
# Fixed for now: Emory → ATL
from_location = Column(String(100), nullable=False, default="Emory University")
to_location = Column(
String(150),
nullable=False,
default="Hartsfield-Jackson Atlanta International Airport",
)
# Full datetime of departure (parsed from SMS)
departure_time = Column(DateTime, nullable=False)
# Always 1 person for now
party_size = Column(Integer, nullable=False, default=1)
# pending → matched → completed → cancelled
status = Column(String(20), nullable=False, default="pending")
# If matched, which other ride is it linked to?
matched_with_ride_id = Column(Integer, ForeignKey("rides.id"), nullable=True)
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)