Restructure the monorepo into clear top-level directories: - backend/: Go module root (cmd, internal, pkg, configs, migrations, docs/swagger, scripts, tests, go.mod, Makefile, .air.toml) - deploy/: Docker (Dockerfile, docker-compose*), quickstart, fluentd - docs/: project documentation + reports/ (moved from repo root) - AGENTS.md: new AI coding-agent guide at repo root Update all references to the new layout: - Dockerfile: COPY backend/go.mod, COPY backend/ (context = repo root) - docker-compose files: context ../.., dockerfile deploy/docker/Dockerfile, env_file ../../.env, volume mounts ../../backend:/app - deploy/quickstart/compose.yaml: dockerfile deploy/docker/Dockerfile - CI: working-directory: backend for go commands, file deploy/docker/Dockerfile, coverage path backend/coverage.out, health_check backend/scripts/ - backend/Makefile: docker target uses -f ../deploy/docker/Dockerfile ../ - README: architecture tree, quickstart, config paths updated Move root stray scripts (rename_models.*, run_m11_tests.sh, verify_build.sh, gorm_bool_main.go) to backend/scripts/legacy/. All moves via git mv to preserve history. Build, vet, SQLite tests, and docker compose config verified.
32 lines
1.8 KiB
Go
32 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
// Audit represents an audit log entry for enterprise compliance.
|
|
// Reference: Chatwoot enterprise Audit model + P2B M11 spec
|
|
type Audit struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
AccountID *uint `gorm:"index" json:"account_id,omitempty"`
|
|
UserID *uint `gorm:"index" json:"user_id,omitempty"`
|
|
AuditableType string `gorm:"size:100;not null;index" json:"auditable_type"` // Conversation/Message/Contact/User/Inbox/Account
|
|
AuditableID uint `gorm:"not null;index" json:"auditable_id"`
|
|
Action string `gorm:"size:100;not null;index" json:"action"` // create/update/delete/assign/unassign/...
|
|
AuditedChanges json.RawMessage `gorm:"type:jsonb;column:audited_changes" json:"audited_changes"`
|
|
AssociatedType string `gorm:"size:100" json:"associated_type,omitempty"` // typically Account
|
|
AssociatedID *uint `gorm:"index" json:"associated_id,omitempty"`
|
|
Username string `gorm:"size:255" json:"username,omitempty"` // operator email, auto-filled
|
|
RemoteAddress string `gorm:"size:50" json:"remote_address,omitempty"` // IP address
|
|
RequestUUID string `gorm:"size:50" json:"request_uuid,omitempty"` // request unique identifier
|
|
Version *int `json:"version,omitempty"`
|
|
Comment string `gorm:"size:500" json:"comment,omitempty"`
|
|
UserType string `gorm:"size:50" json:"user_type,omitempty"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime;index" json:"created_at"`
|
|
|
|
Account *Account `gorm:"foreignKey:AccountID" json:"account,omitempty"`
|
|
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
|
}
|
|
|
|
func (Audit) TableName() string { return "audits" } |