Fix NDA upload to set organization ID
Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
23
pkg/coredata/migrations/20260608T140141Z.sql
Normal file
23
pkg/coredata/migrations/20260608T140141Z.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
--
|
||||
-- Permission to use, copy, modify, and/or distribute this software for any
|
||||
-- purpose with or without fee is hereby granted, provided that the above
|
||||
-- copyright notice and this permission notice appear in all copies.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
-- Backfill organization_id on NDA files that were inserted with the nil GID.
|
||||
-- Before the fix in TrustCenterService.UploadNDA, the OrganizationID field
|
||||
-- was omitted from the File struct.
|
||||
|
||||
UPDATE files
|
||||
SET organization_id = tc.organization_id
|
||||
FROM trust_centers tc
|
||||
WHERE files.organization_id = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
AND files.id = tc.non_disclosure_agreement_file_id;
|
||||
@@ -264,15 +264,16 @@ func (s TrustCenterService) UploadNDA(
|
||||
fileID := gid.New(scope.GetTenantID(), coredata.FileEntityType)
|
||||
|
||||
file = &coredata.File{
|
||||
ID: fileID,
|
||||
BucketName: s.svc.bucket,
|
||||
MimeType: mimeType,
|
||||
FileName: req.FileName,
|
||||
FileKey: objectKey.String(),
|
||||
FileSize: *headOutput.ContentLength,
|
||||
Visibility: coredata.FileVisibilityPrivate,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: fileID,
|
||||
OrganizationID: trustCenter.OrganizationID,
|
||||
BucketName: s.svc.bucket,
|
||||
MimeType: mimeType,
|
||||
FileName: req.FileName,
|
||||
FileKey: objectKey.String(),
|
||||
FileSize: *headOutput.ContentLength,
|
||||
Visibility: coredata.FileVisibilityPrivate,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := file.Insert(ctx, conn, scope); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user