# postgres/append.sql

append.sql — insert-only load, skip rows already present (idempotency)

append.sql — insert-only load, skip rows already present (idempotency)

## Context fields

- `.HistorySchema`
- `.HistoryTable`
- `.StagingSchema`
- `.StagingTable`

## Template

```sql
{{- /* append.sql — insert-only load, skip rows already present (idempotency) */ -}}
{{- /* Also used for dedup_append — semantic distinction is at the agent context level */ -}}
{{- /* Uses ON CONFLICT with the universal UNIQUE(hpk, valid_to) index (ADR-008). */ -}}
INSERT INTO "{{ .HistorySchema }}"."{{ .HistoryTable }}" (
    {{ template "business_col_list" . }}, {{ template "amf_system_cols" . }}
)
SELECT {{ template "business_col_list" . }}, {{ template "amf_system_vals" . }}
FROM   "{{ .StagingSchema }}"."{{ .StagingTable }}" stg
ON CONFLICT (amf_hash_primary_key, amf_valid_to) DO NOTHING
```

## Provenance

| | |
| --- | --- |
| Platform | `postgres` |
| File | `postgres/append.sql` |
| Version | `v1.3.1` |
| Lines | 9 |
| SHA-256 | `1a363aff8b71a404d5ad1d2728070e163de3034196aa2aa4c2141b9449dcecf0` |
