Skip to content

Commit 41bde70

Browse files
committed
fix sql typo bug
1 parent db254a6 commit 41bde70

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

backend/schema.sql

+17-12
Original file line numberDiff line numberDiff line change
@@ -295,21 +295,26 @@ CREATE TABLE thread
295295
-- Each message has both a text_body (plain text) and body (formatted/rich text).
296296
CREATE TABLE message
297297
(
298-
message_id VARCHAR(255) NOT NULL, -- Unique identifier for the message
299-
thread_id VARCHAR(255) NOT NULL, -- Thread this message belongs to
300-
text_body TEXT NOT NULL, -- Plain text content of the message
301-
markdown_body TEXT NOT NULL, -- Rich text/formatted content of the message
302-
html_body TEXT NOT NULL, -- Rich text/formatted html content of the message
303-
customer_id VARCHAR(255) NULL, -- Customer who sent the message (if from customer)
304-
member_id VARCHAR(255) NULL, -- Member who sent the message (if from member)
305-
channel VARCHAR(255) NOT NULL, -- Communication channel used (email, chat, etc)
306-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
307-
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
308-
298+
message_id VARCHAR(255) NOT NULL, -- Unique identifier for the message
299+
thread_id VARCHAR(255) NOT NULL, -- Thread this message belongs to
300+
text_body TEXT NOT NULL, -- Plain text content of the message
301+
markdown_body TEXT NOT NULL, -- Rich text/formatted content of the message
302+
html_body TEXT NOT NULL, -- Rich text/formatted HTML content of the message
303+
customer_id VARCHAR(255) NULL, -- Customer who sent the message (if from customer)
304+
member_id VARCHAR(255) NULL, -- Member who sent the message (if from member)
305+
channel VARCHAR(255) NOT NULL, -- Communication channel used (email, chat, etc)
306+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Timestamp when the message was created
307+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Timestamp when the message was last updated
308+
309+
-- Defining the primary key for the table
309310
CONSTRAINT message_message_id_pkey PRIMARY KEY (message_id),
311+
312+
-- Foreign key constraints
310313
CONSTRAINT message_thread_id_fkey FOREIGN KEY (thread_id) REFERENCES thread (thread_id),
311314
CONSTRAINT message_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES customer (customer_id),
312315
CONSTRAINT message_member_id_fkey FOREIGN KEY (member_id) REFERENCES member (member_id),
316+
317+
-- Check constraint to enforce valid sender (only one of customer_id or member_id can be set)
313318
CONSTRAINT message_sender_check CHECK (
314319
(customer_id IS NULL AND member_id IS NOT NULL) OR
315320
(customer_id IS NOT NULL AND member_id IS NULL)
@@ -327,7 +332,7 @@ CREATE TABLE message_attachment
327332
spam BOOLEAN NOT NULL DEFAULT FALSE,
328333
has_error BOOLEAN NOT NULL DEFAULT FALSE,
329334
error TEXT NOT NULL,
330-
md5_has VARCHAR(511) NOT NULL,
335+
md5_hash VARCHAR(511) NOT NULL,
331336
created_at timestamp DEFAULT CURRENT_TIMESTAMP,
332337
updated_at timestamp DEFAULT CURRENT_TIMESTAMP,
333338

0 commit comments

Comments
 (0)