Docs
postgres/bridge.sql
bridge.sql — DROP legacy bare view (migration guard); CREATE _act and _hst.
bridge.sql — DROP legacy bare view (migration guard); CREATE _act and _hst.
Context fields
.BridgeCols.BridgeSchema.BridgeTable.HistorySchema.HistoryTable
Template
{{- /* bridge.sql — DROP legacy bare view (migration guard); CREATE _act and _hst.
All history tables now have universal columns (DESIGN-012), so bridge views
always use the same SCD2-style projection regardless of history mode. */ -}}
DROP VIEW IF EXISTS "{{ .BridgeSchema }}"."{{ .BridgeTable }}";
DROP VIEW IF EXISTS "{{ .BridgeSchema }}"."{{ .BridgeTable }}_act";
DROP VIEW IF EXISTS "{{ .BridgeSchema }}"."{{ .BridgeTable }}_hst";
CREATE VIEW "{{ .BridgeSchema }}"."{{ .BridgeTable }}_act" AS
SELECT
{{- $first := true }}
{{- range $i, $col := .BridgeCols }}
{{- if $col.Include }}
{{- if $first }}
{{ $col.ProjectionExpr }}{{ if $col.HasAlias }} AS {{ $col.TargetName }}{{ end }}
{{- $first = false }}
{{- else }}
,{{ $col.ProjectionExpr }}{{ if $col.HasAlias }} AS {{ $col.TargetName }}{{ end }}
{{- end }}
{{- end }}
{{- end }}
,amf_run_id
,amf_valid_from
,amf_updated_at
FROM "{{ .HistorySchema }}"."{{ .HistoryTable }}"
WHERE amf_valid_to IS NULL;
CREATE VIEW "{{ .BridgeSchema }}"."{{ .BridgeTable }}_hst" AS
SELECT
{{- $first2 := true }}
{{- range $i, $col := .BridgeCols }}
{{- if $col.Include }}
{{- if $first2 }}
{{ $col.ProjectionExpr }}{{ if $col.HasAlias }} AS {{ $col.TargetName }}{{ end }}
{{- $first2 = false }}
{{- else }}
,{{ $col.ProjectionExpr }}{{ if $col.HasAlias }} AS {{ $col.TargetName }}{{ end }}
{{- end }}
{{- end }}
{{- end }}
,amf_run_id
,amf_valid_from
,amf_valid_to
,amf_updated_at
FROM "{{ .HistorySchema }}"."{{ .HistoryTable }}"Provenance
| Platform | postgres |
| File | postgres/bridge.sql |
| Version | v1.3.1 |
| Lines | 44 |
| SHA-256 | 6af2fff2f0c596fceca0e938c9336f61f76df3e62f501786147cab82363a7dd9 |
Last updated on October 11, 2026