Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit 8e7f326

Browse files
committed
Review feedback
1 parent 4c9c025 commit 8e7f326

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pkg/config/cleanup_server_config.go

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package config
1616

1717
import (
1818
"context"
19+
"fmt"
1920
"time"
2021

2122
"github.com/google/exposure-notifications-verification-server/pkg/database"
@@ -65,6 +66,7 @@ func (c *CleanupConfig) Validate() error {
6566
{c.CleanupPeriod, "CLEANUP_PERIOD"},
6667
{c.VerificationCodeMaxAge, "VERIFICATION_CODE_MAX_AGE"},
6768
{c.VerificationTokenMaxAge, "VERIFICATION_TOKEN_MAX_AGE"},
69+
{c.AuditEntryMaxAge, "AUDIT_ENTRY_MAX_AGE"},
6870
}
6971

7072
for _, f := range fields {
@@ -73,6 +75,11 @@ func (c *CleanupConfig) Validate() error {
7375
}
7476
}
7577

78+
// Audit entries need to persist for at least 7 days. The default is 30d ays.
79+
if c.AuditEntryMaxAge < 7*24*time.Hour {
80+
return fmt.Errorf("AUDIT_ENTRY_MAX_AGE must be at least 7 days")
81+
}
82+
7683
return nil
7784
}
7885

pkg/database/audit_entry.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type AuditEntry struct {
5151

5252
// TargetID and TargetDisplay are the same as the actor, but are for the
5353
// target of the action.
54-
TargetID string `gorm:"column:target_name; type:text; not null;"`
54+
TargetID string `gorm:"column:target_id; type:text; not null;"`
5555
TargetDisplay string `gorm:"column:target_display; type:text; not null;"`
5656

5757
// Diff is the change of structure that occurred, if any.

pkg/database/migrations.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,8 @@ func (db *Database) getMigrations(ctx context.Context) *gormigrate.Gormigrate {
13761376

13771377
sqls := []string{
13781378
`CREATE INDEX IF NOT EXISTS idx_audit_entries_realm_id ON audit_entries (realm_id)`,
1379-
`CREATE INDEX IF NOT EXISTS idx_audit_entries_actor_id ON audit_entries (realm_id)`,
1379+
`CREATE INDEX IF NOT EXISTS idx_audit_entries_actor_id ON audit_entries (actor_id)`,
1380+
`CREATE INDEX IF NOT EXISTS idx_audit_entries_target_id ON audit_entries (target_id)`,
13801381
`CREATE INDEX IF NOT EXISTS idx_audit_entries_created_at ON audit_entries (created_at)`,
13811382
}
13821383

0 commit comments

Comments
 (0)