Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions frontend/src/services/api.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ export const medicalRecordService = {
};

export const attachmentService = {
upload: (recordId, formData) => api.post(`/attachments/record/${recordId}`, formData),

// Content-Type sätts till undefined så att browsern själv sätter
// multipart/form-data med korrekt boundary. Annars ärver anropet
// axios-instansens globala application/json och backenden svarar 415.
upload: (recordId, formData) => api.post(`/attachments/record/${recordId}`, formData, {
headers: { 'Content-Type': undefined }
}),

getByRecord: (recordId) => api.get(`/attachments/record/${recordId}`),
download: (id) => api.get(`/attachments/${id}/download`, { responseType: 'blob' }),
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ CREATE TABLE IF NOT EXISTS attachment (
uploaded_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Migration för befintliga databaser som skapades innan description-kolumnen lades till.
-- CREATE TABLE IF NOT EXISTS ovan är no-op om tabellen redan finns, så kolumnen måste
-- läggas till explicit. Samma mönster som comment_type ovan.
ALTER TABLE attachment ADD COLUMN IF NOT EXISTS description VARCHAR(500);

CREATE TABLE IF NOT EXISTS activity_log (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
record_id UUID REFERENCES medical_record(id),
Expand Down