- Added file attachment support in chat messages, allowing users to upload and send files. - Implemented a new API endpoint to retrieve message attachments. - Updated chat components to display attachments and handle file uploads. - Improved user experience with loading indicators and toast notifications for file uploads. - Refactored chat bottom bar to integrate file upload functionality seamlessly. - Enhanced chat list to show attachments associated with messages. - Updated database schema to support attachments in chat messages. Co-authored-by: Copilot <copilot@github.com>
42 lines
No EOL
1.2 KiB
SQL
42 lines
No EOL
1.2 KiB
SQL
CREATE TABLE IF NOT EXISTS public.messages_attachments
|
|
(
|
|
"messageId" uuid NOT NULL,
|
|
"userStorageId" uuid NOT NULL
|
|
);
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1 FROM pg_constraint
|
|
WHERE conname = 'messages_attachments_pkey'
|
|
AND conrelid = 'public.messages_attachments'::regclass
|
|
) THEN
|
|
ALTER TABLE public.messages_attachments
|
|
ADD CONSTRAINT messages_attachments_pkey PRIMARY KEY ("messageId", "userStorageId");
|
|
END IF;
|
|
END $$;
|
|
|
|
|
|
DO $$ BEGIN IF NOT EXISTS (
|
|
SELECT 1 FROM pg_constraint
|
|
WHERE conname = 'msg_attach_msgid'
|
|
AND conrelid = 'public.messages_attachments'::regclass
|
|
) THEN
|
|
ALTER TABLE public.messages_attachments
|
|
ADD CONSTRAINT msg_attach_msgid
|
|
FOREIGN KEY ("messageId") REFERENCES public.messages (messageid)
|
|
ON UPDATE CASCADE ON DELETE CASCADE;
|
|
END IF;
|
|
END $$;
|
|
|
|
DO $$ BEGIN IF NOT EXISTS (
|
|
SELECT 1 FROM pg_constraint
|
|
WHERE conname = 'msg_attach_storageid'
|
|
AND conrelid = 'public.messages_attachments'::regclass
|
|
) THEN
|
|
ALTER TABLE public.messages_attachments
|
|
ADD CONSTRAINT msg_attach_storageid
|
|
FOREIGN KEY ("userStorageId") REFERENCES public.users_storage (user_storage_id)
|
|
ON UPDATE CASCADE ON DELETE CASCADE;
|
|
END IF;
|
|
END $$; |