File size: 2,342 Bytes
b6f0f70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import uuid # uuid is used to generate a random unique id for each user
from .database import Base
from sqlalchemy import TIMESTAMP, Column, String, Boolean, text, Enum
from sqlalchemy.dialects.postgresql import UUID

# User model
class User(Base):
    __tablename__ = 'users'
    id = Column(UUID(as_uuid=True), primary_key=True, nullable=False,
                default=uuid.uuid4)
    name = Column(String,  nullable=False)
    email = Column(String, unique=True, nullable=False)
    password = Column(String, nullable=False)
    verified = Column(Boolean, nullable=False, server_default='False')
    role = Column(String, server_default='user', nullable=False)
    created_at = Column(TIMESTAMP(timezone=True),
                        nullable=False, server_default=text("now()"))
    updated_at = Column(TIMESTAMP(timezone=True),
                        nullable=False, server_default=text("now()"))

class Pet(Base):
    __tablename__ = 'pets'
    id = Column(UUID(as_uuid=True), primary_key=True, nullable=False,
                default=uuid.uuid4)
    name = Column(String, nullable=False)
    age = Column(String, nullable=False)
    gender = Column(Enum('Jantan', 'Betina', name='gender'), nullable=False)
    created_at = Column(TIMESTAMP(timezone=True),
                        nullable=False, server_default=text("now()"))
    updated_at = Column(TIMESTAMP(timezone=True),
                        nullable=False, server_default=text("now()"))
    
class Doctor(Base):
    __tablename__ = 'doctors'
    id = Column(UUID(as_uuid=True), primary_key=True, nullable=False,
                default=uuid.uuid4)
    name = Column(String, unique=True, nullable=False)
    price = Column(String, nullable=False)
    rating = Column(String, nullable=False)
    role = Column(String, server_default='Hewan', nullable=False)
    role_detail = Column(String, nullable=False)
    day = Column(String, nullable=True)
    time = Column(String, nullable=False)
    location = Column(String, nullable=False)
    university = Column(String, nullable=False)
    yearofexperience = Column(String, nullable=False)
    created_at = Column(TIMESTAMP(timezone=True),
                        nullable=False, server_default=text("now()"))
    updated_at = Column(TIMESTAMP(timezone=True),
                        nullable=False, server_default=text("now()"))