finish updating schema for termails

This commit is contained in:
Keiran 2025-08-06 06:30:55 +01:00
parent f99343fea8
commit a19c475d2a

View File

@ -72,13 +72,19 @@ func CreateTables() error {
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS messages (
CREATE TABLE IF NOT EXISTS termails (
id SERIAL PRIMARY KEY,
sender_id INT REFERENCES users(id),
receiver_id INT REFERENCES users(id),
subject VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
is_read BOOLEAN DEFAULT FALSE,
sent_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_termails_receiver_id ON termails(receiver_id);
CREATE INDEX IF NOT EXISTS idx_termails_sender_id ON termails(sender_id);
CREATE INDEX IF NOT EXISTS idx_termails_sent_at ON termails(sent_at);
`)
return err