@@ -41,7 +41,7 @@ class User(Base):
41
41
__tablename__ = "users"
42
42
43
43
id = Column (types .Uuid , primary_key = True ) # type: ignore[attr-defined]
44
- name = Column (types .String )
44
+ name = Column (types .String , nullable = False )
45
45
46
46
47
47
document_chat_association_table = Table (
@@ -57,10 +57,10 @@ class Document(Base):
57
57
58
58
id = Column (types .Uuid , primary_key = True ) # type: ignore[attr-defined]
59
59
user_id = Column (ForeignKey ("users.id" ))
60
- name = Column (types .String )
60
+ name = Column (types .String , nullable = False )
61
61
# Mind the trailing underscore here. Unfortunately, this is necessary, because
62
62
# metadata without the underscore is reserved by SQLAlchemy
63
- metadata_ = Column (Json )
63
+ metadata_ = Column (Json , nullable = False )
64
64
chats = relationship (
65
65
"Chat" ,
66
66
secondary = document_chat_association_table ,
@@ -77,19 +77,19 @@ class Chat(Base):
77
77
78
78
id = Column (types .Uuid , primary_key = True ) # type: ignore[attr-defined]
79
79
user_id = Column (ForeignKey ("users.id" ))
80
- name = Column (types .String )
80
+ name = Column (types .String , nullable = False )
81
81
documents = relationship (
82
82
"Document" ,
83
83
secondary = document_chat_association_table ,
84
84
back_populates = "chats" ,
85
85
)
86
- source_storage = Column (types .String )
87
- assistant = Column (types .String )
88
- params = Column (Json )
86
+ source_storage = Column (types .String , nullable = False )
87
+ assistant = Column (types .String , nullable = False )
88
+ params = Column (Json , nullable = False )
89
89
messages = relationship (
90
90
"Message" , cascade = "all, delete" , order_by = "Message.timestamp"
91
91
)
92
- prepared = Column (types .Boolean )
92
+ prepared = Column (types .Boolean , nullable = False )
93
93
94
94
95
95
source_message_association_table = Table (
@@ -111,9 +111,9 @@ class Source(Base):
111
111
document_id = Column (ForeignKey ("documents.id" ))
112
112
document = relationship ("Document" , back_populates = "sources" )
113
113
114
- location = Column (types .String )
115
- content = Column (types .String )
116
- num_tokens = Column (types .Integer )
114
+ location = Column (types .String , nullable = False )
115
+ content = Column (types .String , nullable = False )
116
+ num_tokens = Column (types .Integer , nullable = False )
117
117
118
118
messages = relationship (
119
119
"Message" ,
@@ -127,11 +127,11 @@ class Message(Base):
127
127
128
128
id = Column (types .Uuid , primary_key = True ) # type: ignore[attr-defined]
129
129
chat_id = Column (ForeignKey ("chats.id" ))
130
- content = Column (types .String )
131
- role = Column (types .Enum (MessageRole ))
130
+ content = Column (types .String , nullable = False )
131
+ role = Column (types .Enum (MessageRole ), nullable = False )
132
132
sources = relationship (
133
133
"Source" ,
134
134
secondary = source_message_association_table ,
135
135
back_populates = "messages" ,
136
136
)
137
- timestamp = Column (types .DateTime )
137
+ timestamp = Column (types .DateTime , nullable = False )
0 commit comments