Files
aura-crm/production/backend/migrations/010_document_templates.sql
T

18 lines
918 B
SQL

-- +goose Up
-- Owner-editable block layout behind the Счёт/Акт PDFs — see
-- internal/doctemplates and internal/pdfgen/blocks.go. One row per document
-- kind (invoice/act), shared by both order and cartridge-batch documents,
-- since pdfgen.GenerateInvoice/GenerateAct never distinguished between the
-- two callers to begin with. No seed rows: internal/doctemplates.Fetch
-- returns the Go-computed default (pdfgen.DefaultInvoiceBlocks/
-- DefaultActBlocks) whenever a kind has no row yet, so a fresh deployment
-- renders exactly what this app always rendered before templates existed,
-- until an owner opens the editor and actually saves one.
CREATE TABLE document_templates (
kind TEXT PRIMARY KEY CHECK (kind IN ('invoice', 'act')),
blocks JSONB NOT NULL,
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_by_staff_name TEXT
);