# postgres/replace.sql

replace.sql — truncate history then re-insert full staging set (no versioning)

replace.sql — truncate history then re-insert full staging set (no versioning)

## Context fields

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

## Template

```sql
{{- /* replace.sql — truncate history then re-insert full staging set (no versioning) */ -}}
TRUNCATE "{{ .HistorySchema }}"."{{ .HistoryTable }}";

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
```

## Provenance

| | |
| --- | --- |
| Platform | `postgres` |
| File | `postgres/replace.sql` |
| Version | `v1.3.1` |
| Lines | 8 |
| SHA-256 | `521202134628c11287e7bb0108fbc3f711e4d58426f616753f01bb9a5da6f182` |
