Move document_records duty-slot writes into docgov, project ledger heads through docgov/freedoc ports, and workspace deliverable I/O through DeliverableStore so arch-check baseline drops to sql_write:1 path:13.
30 lines
833 B
Go
30 lines
833 B
Go
package freedoc
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"chat-agent-system/internal/app/uow"
|
|
)
|
|
|
|
// Repository writes freeform_documents root pointers inside a UnitOfWork scope.
|
|
type Repository struct{}
|
|
|
|
// ProjectHead projects ledger head pointers onto freeform_documents.
|
|
func (Repository) ProjectHead(ctx context.Context, scope uow.TxScope, docID string, versionID, snapshotID *int64, revisionNo, schemaVer int) error {
|
|
tx, err := uow.AsPG(scope)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = tx.Exec(ctx, `
|
|
UPDATE freeform_documents
|
|
SET ledger_version_id=$2, head_snapshot_id=$3, head_revision_no=$4,
|
|
revision_schema_version=$5, row_revision=COALESCE(row_revision,0)+1
|
|
WHERE doc_id=$1`,
|
|
docID, versionID, snapshotID, revisionNo, schemaVer)
|
|
if err != nil {
|
|
return fmt.Errorf("freedoc: project head: %w", err)
|
|
}
|
|
return nil
|
|
}
|