File size: 1,243 Bytes
1b7f275
 
 
 
 
 
 
 
 
 
 
 
 
8f85807
1b7f275
 
 
 
43e42ab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from sqlalchemy import Column, Integer, String, Boolean
from sqlalchemy.orm import relationship
from .base_class import Base


class User(Base):
    __tablename__ = "users"  # ชื่อตารางในฐานข้อมูล

    # คอลัมน์ต่างๆ ในตาราง users
    # id, email, hashed_password, is_active, first_name, last_name
    # String(255) กำหนดความยาวสูงสุดของสตริง
    # String ไม่ได้กำหนดความยาวสูงสุดจึงใช้สำหรับข้อมูลที่ยาวไม่จำกัด
    id = Column(Integer, primary_key=True, index=True)  # รหัสผู้ใช้
    profile_image_url = Column(String(512), nullable=True)
    first_name = Column(String(128), nullable=False)  # ชื่อจริง
    last_name = Column(String(128), nullable=False)  # นามสกุล
    email = Column(String(255), unique=True, index=True, nullable=False)  # อีเมล
    hashed_password = Column(String(255), nullable=False)  # รหัสผ่านที่ถูกเข้ารหัส
    role = Column(String(50), nullable=False, default="user")