1- from sqlalchemy import Column , Integer , String , Enum , TIMESTAMP , text
1+ from sqlalchemy import Column , Integer , String , Boolean , TIMESTAMP , ForeignKey , text
22from sqlalchemy .orm import relationship
3+ from .base import Base
34
4- class User (Base ):
5- __tablename__ = "user "
5+ class Checklist (Base ):
6+ __tablename__ = "checklist "
67
7- u_id = Column (Integer , primary_key = True , autoincrement = True ) # PK
8- id = Column (String (50 ), unique = True , nullable = False ) # 로그인 ID
9- email = Column (String (150 ), unique = True , nullable = False )
10- password = Column (String (255 ), nullable = False )
11- provider = Column (
12- Enum ("local" , "google" , "kakao" , "naver" , name = "provider_enum" ),
13- nullable = False ,
14- server_default = "local" ,
15- )
16- created_at = Column (
17- TIMESTAMP , nullable = False , server_default = text ("CURRENT_TIMESTAMP" )
18- )
19- updated_at = Column (
20- TIMESTAMP ,
21- nullable = False ,
22- server_default = text ("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" ),
23- )
8+ id = Column (Integer , primary_key = True , autoincrement = True )
9+ user_id = Column (Integer , ForeignKey ("user.u_id" , ondelete = "CASCADE" ), nullable = False )
10+ title = Column (String (255 ), nullable = False )
11+ is_clear = Column (Boolean , nullable = False , server_default = text ("0" ))
12+ created_at = Column (TIMESTAMP , nullable = False , server_default = text ("CURRENT_TIMESTAMP" ))
13+ updated_at = Column (TIMESTAMP , nullable = False ,
14+ server_default = text ("CURRENT_TIMESTAMP" ),
15+ onupdate = text ("CURRENT_TIMESTAMP" ))
2416
25- # 역참조: checklist 목록
26- checklists = relationship ("Checklist" , back_populates = "user" , cascade = "all, delete-orphan" )
17+ user = relationship ("User" , back_populates = "checklists" )
0 commit comments