1+ from sqlalchemy import Column , String , Integer , ForeignKey , Enum
2+ from sqlalchemy .orm import Mapped , mapped_column
3+ from extension import db
14
5+ class Plan (db .Model ):
6+ __tablename__ = "plan"
7+
8+ id = Column (Integer , primary_key = True , nullable = False )
9+ name = Column (String , nullable = False )
10+ description = Column (String (300 ), nullable = True )
11+ amount = Column (Integer , nullable = False )
12+ intervals = Column (Integer , nullable = False )
13+ plan_id = Column (String )
14+
15+ class Subscription (db .Model ):
16+ __tablename__ = "subscription"
17+
18+ STATUS_CHOICES = ["active" , "disabled" ]
19+
20+ id = Column (Integer , primary_key = True , nullable = False )
21+ plan_id = Column (Integer , ForeignKey (Plan .id ), nullable = False )
22+ razorpay_user_id = Column (String )
23+ subscription_id = Column (String )
24+ subscription_status = Column (
25+ Enum (* STATUS_CHOICES , name = "status" , native_enum = False ),
26+ nullable = False ,
27+ default = "active" ,
28+ )
29+
230
3- # engine = create_engine('postgresql:///tutorial.db', echo=True)
4- def hello ():
5- print ("Hello from database.py" )
6- print ("========== Database connection established successfully ==========" )
31+ class User (db .Model ):
32+ __tablename__ = "user"
33+ id = Column (Integer , primary_key = True , nullable = False )
34+ name = Column (String , nullable = False )
35+ email = Column (String , nullable = False )
36+ phone_number = Column (String , nullable = False )
37+
0 commit comments