- Backend: Email producer (LavinMQ), EmailService interface - Backend: CRUD API for email_templates and email_settings - Backend: avatar_url field in users table + UpdateMyProfile support - Backend: StorageService for pre-signed URLs - NestJS: Email consumer with Nodemailer and Handlebars - Frontend: Email Templates admin pages (list/edit) - Frontend: Updated profileApi.uploadAvatar with pre-signed URL flow - Frontend: New /post-job public page (company registration + job creation wizard) - Migrations: 027_create_email_system.sql, 028_add_avatar_url_to_users.sql
32 lines
1.5 KiB
SQL
32 lines
1.5 KiB
SQL
-- Migration: Create chat tables (conversations, messages)
|
|
-- Description: Stores chat history for candidate-company communication
|
|
|
|
CREATE TABLE IF NOT EXISTS conversations (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
candidate_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
company_id UUID NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
|
job_id UUID REFERENCES jobs(id) ON DELETE SET NULL,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
last_message TEXT,
|
|
last_message_at TIMESTAMP WITH TIME ZONE
|
|
);
|
|
|
|
CREATE INDEX idx_conversations_candidate ON conversations(candidate_id);
|
|
CREATE INDEX idx_conversations_company ON conversations(company_id);
|
|
CREATE INDEX idx_conversations_updated ON conversations(updated_at DESC);
|
|
|
|
CREATE TABLE IF NOT EXISTS messages (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
conversation_id UUID NOT NULL REFERENCES conversations(id) ON DELETE CASCADE,
|
|
sender_id UUID NOT NULL REFERENCES users(id),
|
|
content TEXT NOT NULL,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
appwrite_id VARCHAR(255)
|
|
);
|
|
|
|
CREATE INDEX idx_messages_conversation ON messages(conversation_id);
|
|
CREATE INDEX idx_messages_created ON messages(created_at);
|
|
|
|
COMMENT ON TABLE conversations IS 'Chat conversations between candidates and companies';
|
|
COMMENT ON TABLE messages IS 'Individual chat messages synchronized with Appwrite';
|