Remove audit link to registries
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -33,7 +33,6 @@ type (
|
||||
ReferenceID string `db:"reference_id"`
|
||||
Area *string `db:"area"`
|
||||
Source *string `db:"source"`
|
||||
AuditID gid.GID `db:"audit_id"`
|
||||
Requirement *string `db:"requirement"`
|
||||
ActionsToBeImplemented *string `db:"actions_to_be_implemented"`
|
||||
Regulator *string `db:"regulator"`
|
||||
@@ -78,7 +77,6 @@ SELECT
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
audit_id,
|
||||
requirement,
|
||||
actions_to_be_implemented,
|
||||
regulator,
|
||||
@@ -162,7 +160,6 @@ SELECT
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
audit_id,
|
||||
requirement,
|
||||
actions_to_be_implemented,
|
||||
regulator,
|
||||
@@ -214,7 +211,6 @@ INSERT INTO compliance_registries (
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
audit_id,
|
||||
requirement,
|
||||
actions_to_be_implemented,
|
||||
regulator,
|
||||
@@ -231,7 +227,6 @@ INSERT INTO compliance_registries (
|
||||
@reference_id,
|
||||
@area,
|
||||
@source,
|
||||
@audit_id,
|
||||
@requirement,
|
||||
@actions_to_be_implemented,
|
||||
@regulator,
|
||||
@@ -251,7 +246,6 @@ INSERT INTO compliance_registries (
|
||||
"reference_id": cr.ReferenceID,
|
||||
"area": cr.Area,
|
||||
"source": cr.Source,
|
||||
"audit_id": cr.AuditID,
|
||||
"requirement": cr.Requirement,
|
||||
"actions_to_be_implemented": cr.ActionsToBeImplemented,
|
||||
"regulator": cr.Regulator,
|
||||
@@ -281,7 +275,6 @@ UPDATE compliance_registries SET
|
||||
reference_id = @reference_id,
|
||||
area = @area,
|
||||
source = @source,
|
||||
audit_id = @audit_id,
|
||||
requirement = @requirement,
|
||||
actions_to_be_implemented = @actions_to_be_implemented,
|
||||
regulator = @regulator,
|
||||
@@ -302,7 +295,6 @@ WHERE
|
||||
"reference_id": cr.ReferenceID,
|
||||
"area": cr.Area,
|
||||
"source": cr.Source,
|
||||
"audit_id": cr.AuditID,
|
||||
"requirement": cr.Requirement,
|
||||
"actions_to_be_implemented": cr.ActionsToBeImplemented,
|
||||
"regulator": cr.Regulator,
|
||||
|
||||
@@ -32,7 +32,6 @@ type (
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
ReferenceID string `db:"reference_id"`
|
||||
Description *string `db:"description"`
|
||||
AuditID gid.GID `db:"audit_id"`
|
||||
Source *string `db:"source"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
TargetDate *time.Time `db:"target_date"`
|
||||
@@ -74,7 +73,6 @@ SELECT
|
||||
organization_id,
|
||||
reference_id,
|
||||
description,
|
||||
audit_id,
|
||||
source,
|
||||
owner_id,
|
||||
target_date,
|
||||
@@ -155,7 +153,6 @@ SELECT
|
||||
organization_id,
|
||||
reference_id,
|
||||
description,
|
||||
audit_id,
|
||||
source,
|
||||
owner_id,
|
||||
target_date,
|
||||
@@ -204,7 +201,6 @@ INSERT INTO continual_improvement_registries (
|
||||
organization_id,
|
||||
reference_id,
|
||||
description,
|
||||
audit_id,
|
||||
source,
|
||||
owner_id,
|
||||
target_date,
|
||||
@@ -218,7 +214,6 @@ INSERT INTO continual_improvement_registries (
|
||||
@organization_id,
|
||||
@reference_id,
|
||||
@description,
|
||||
@audit_id,
|
||||
@source,
|
||||
@owner_id,
|
||||
@target_date,
|
||||
@@ -235,7 +230,6 @@ INSERT INTO continual_improvement_registries (
|
||||
"organization_id": cir.OrganizationID,
|
||||
"reference_id": cir.ReferenceID,
|
||||
"description": cir.Description,
|
||||
"audit_id": cir.AuditID,
|
||||
"source": cir.Source,
|
||||
"owner_id": cir.OwnerID,
|
||||
"target_date": cir.TargetDate,
|
||||
@@ -262,7 +256,6 @@ func (cir *ContinualImprovementRegistry) Update(
|
||||
UPDATE continual_improvement_registries SET
|
||||
reference_id = @reference_id,
|
||||
description = @description,
|
||||
audit_id = @audit_id,
|
||||
source = @source,
|
||||
owner_id = @owner_id,
|
||||
target_date = @target_date,
|
||||
@@ -280,7 +273,6 @@ WHERE
|
||||
"id": cir.ID,
|
||||
"reference_id": cir.ReferenceID,
|
||||
"description": cir.Description,
|
||||
"audit_id": cir.AuditID,
|
||||
"source": cir.Source,
|
||||
"owner_id": cir.OwnerID,
|
||||
"target_date": cir.TargetDate,
|
||||
|
||||
@@ -36,7 +36,6 @@ CREATE TABLE processing_activity_registries (
|
||||
id TEXT PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL,
|
||||
organization_id TEXT NOT NULL,
|
||||
audit_id TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
purpose TEXT,
|
||||
data_subject_category TEXT,
|
||||
@@ -59,11 +58,5 @@ CREATE TABLE processing_activity_registries (
|
||||
FOREIGN KEY (organization_id)
|
||||
REFERENCES organizations(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE,
|
||||
|
||||
CONSTRAINT processing_activity_registries_audit_id_fkey
|
||||
FOREIGN KEY (audit_id)
|
||||
REFERENCES audits(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
5
pkg/coredata/migrations/20250828T120643Z.sql
Normal file
5
pkg/coredata/migrations/20250828T120643Z.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE compliance_registries DROP CONSTRAINT compliance_registries_audit_id_fkey;
|
||||
ALTER TABLE compliance_registries DROP COLUMN audit_id;
|
||||
|
||||
ALTER TABLE continual_improvement_registries DROP CONSTRAINT continual_improvement_registries_audit_id_fkey;
|
||||
ALTER TABLE continual_improvement_registries DROP COLUMN audit_id;
|
||||
@@ -30,7 +30,6 @@ type (
|
||||
ProcessingActivityRegistry struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
AuditID gid.GID `db:"audit_id"`
|
||||
Name string `db:"name"`
|
||||
Purpose *string `db:"purpose"`
|
||||
DataSubjectCategory *string `db:"data_subject_category"`
|
||||
@@ -74,7 +73,6 @@ func (p *ProcessingActivityRegistry) LoadByID(
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
audit_id,
|
||||
name,
|
||||
purpose,
|
||||
data_subject_category,
|
||||
@@ -163,7 +161,6 @@ func (p *ProcessingActivityRegistries) LoadByOrganizationID(
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
audit_id,
|
||||
name,
|
||||
purpose,
|
||||
data_subject_category,
|
||||
@@ -210,96 +207,6 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ProcessingActivityRegistries) CountByAuditID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
auditID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
COUNT(id)
|
||||
FROM
|
||||
processing_activity_registries
|
||||
WHERE
|
||||
%s
|
||||
AND audit_id = @audit_id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"audit_id": auditID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
row := conn.QueryRow(ctx, q, args)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count processing activity registries: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (p *ProcessingActivityRegistries) LoadByAuditID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
auditID gid.GID,
|
||||
cursor *page.Cursor[ProcessingActivityRegistryOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
audit_id,
|
||||
name,
|
||||
purpose,
|
||||
data_subject_category,
|
||||
personal_data_category,
|
||||
special_or_criminal_data,
|
||||
consent_evidence_link,
|
||||
lawful_basis,
|
||||
recipients,
|
||||
location,
|
||||
international_transfers,
|
||||
transfer_safeguards,
|
||||
retention_period,
|
||||
security_measures,
|
||||
data_protection_impact_assessment,
|
||||
transfer_impact_assessment,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
processing_activity_registries
|
||||
WHERE
|
||||
%s
|
||||
AND audit_id = @audit_id
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"audit_id": auditID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query processing activity registries: %w", err)
|
||||
}
|
||||
|
||||
processingActivityRegistries, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ProcessingActivityRegistry])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect processing activity registries: %w", err)
|
||||
}
|
||||
|
||||
*p = processingActivityRegistries
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ProcessingActivityRegistry) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
@@ -310,7 +217,6 @@ INSERT INTO processing_activity_registries (
|
||||
id,
|
||||
tenant_id,
|
||||
organization_id,
|
||||
audit_id,
|
||||
name,
|
||||
purpose,
|
||||
data_subject_category,
|
||||
@@ -332,7 +238,6 @@ INSERT INTO processing_activity_registries (
|
||||
@id,
|
||||
@tenant_id,
|
||||
@organization_id,
|
||||
@audit_id,
|
||||
@name,
|
||||
@purpose,
|
||||
@data_subject_category,
|
||||
@@ -357,7 +262,6 @@ INSERT INTO processing_activity_registries (
|
||||
"id": p.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": p.OrganizationID,
|
||||
"audit_id": p.AuditID,
|
||||
"name": p.Name,
|
||||
"purpose": p.Purpose,
|
||||
"data_subject_category": p.DataSubjectCategory,
|
||||
@@ -395,7 +299,6 @@ UPDATE processing_activity_registries
|
||||
SET
|
||||
name = @name,
|
||||
purpose = @purpose,
|
||||
audit_id = @audit_id,
|
||||
data_subject_category = @data_subject_category,
|
||||
personal_data_category = @personal_data_category,
|
||||
special_or_criminal_data = @special_or_criminal_data,
|
||||
@@ -421,7 +324,6 @@ WHERE
|
||||
"id": p.ID,
|
||||
"name": p.Name,
|
||||
"purpose": p.Purpose,
|
||||
"audit_id": p.AuditID,
|
||||
"data_subject_category": p.DataSubjectCategory,
|
||||
"personal_data_category": p.PersonalDataCategory,
|
||||
"special_or_criminal_data": p.SpecialOrCriminalData,
|
||||
|
||||
Reference in New Issue
Block a user