From 5b3fca4de832facf8365d63e5e7560083a76c9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Thu, 4 Dec 2025 19:03:18 +0400 Subject: [PATCH] Fix missing organization ID on reports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- pkg/coredata/migrations/20251204T000000Z.sql | 8 ++++++++ pkg/probo/audit_service.go | 15 ++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 pkg/coredata/migrations/20251204T000000Z.sql diff --git a/pkg/coredata/migrations/20251204T000000Z.sql b/pkg/coredata/migrations/20251204T000000Z.sql new file mode 100644 index 000000000..65e128260 --- /dev/null +++ b/pkg/coredata/migrations/20251204T000000Z.sql @@ -0,0 +1,8 @@ +UPDATE + reports +SET + organization_id = a.organization_id +FROM + audits a +WHERE + reports.tenant_id = a.tenant_id; diff --git a/pkg/probo/audit_service.go b/pkg/probo/audit_service.go index 6206f0576..4467a451c 100644 --- a/pkg/probo/audit_service.go +++ b/pkg/probo/audit_service.go @@ -346,13 +346,14 @@ func (s AuditService) UploadReport( } report := &coredata.Report{ - ID: reportID, - ObjectKey: objectKey.String(), - MimeType: req.File.ContentType, - Filename: req.File.Filename, - Size: req.File.Size, - CreatedAt: now, - UpdatedAt: now, + ID: reportID, + OrganizationID: audit.OrganizationID, + ObjectKey: objectKey.String(), + MimeType: req.File.ContentType, + Filename: req.File.Filename, + Size: req.File.Size, + CreatedAt: now, + UpdatedAt: now, } if err := report.Insert(ctx, conn, s.svc.scope); err != nil {