FDN-01: repository & projektgerüst
Git-Repository für bestehenden archivdms-Code initialisiert, Branch-/Commit-Konvention (feature/<ticket>-<slug>-Branches, Ticket-Prefix in Commit-Nachricht) etabliert.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
-- PROJ: Digitale Akte (digitaler Aktenordner) — Gruppierung von Dokumenten.
|
||||
-- Doku-only (siehe README.md in diesem Verzeichnis) — die tatsächliche
|
||||
-- Ausführung passiert idempotent über
|
||||
-- internal/storage/documents.go (*Store).initSchema() -> initAktenSchema
|
||||
-- (internal/storage/akten.go). Source of Truth bleibt der Go-Code.
|
||||
--
|
||||
-- Strikt 1:n zu Dokumenten via documents.akte_id (kein Join-Table): ein
|
||||
-- Dokument gehört zu maximal einer Akte. ON DELETE SET NULL ist die
|
||||
-- GoBD-Absicherung — eine Akte löschen kann strukturell nie Dokumente löschen,
|
||||
-- sondern entkoppelt sie nur. Keine eigene ACL: die Sichtbarkeit einer Akte
|
||||
-- erbt von den enthaltenen Dokumenten (EXISTS gegen document_visibility,
|
||||
-- gleiches Pattern wie ListDocuments). Siehe project_akte_konzept_plan.md.
|
||||
--
|
||||
-- Reihenfolge: akten-Tabelle muss VOR der ALTER TABLE auf documents existieren,
|
||||
-- da documents.akte_id auf akten(id) verweist. correspondent_id verweist auf
|
||||
-- correspondents(id) (initTaxonomySchema läuft davor).
|
||||
|
||||
CREATE TABLE IF NOT EXISTS akten (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
tenant_id BIGINT NOT NULL,
|
||||
titel TEXT NOT NULL,
|
||||
beschreibung TEXT NOT NULL DEFAULT '',
|
||||
status TEXT NOT NULL DEFAULT 'offen' CHECK (status IN ('offen','geschlossen')),
|
||||
correspondent_id BIGINT REFERENCES correspondents(id),
|
||||
created_by BIGINT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
closed_at TIMESTAMPTZ
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_akten_tenant ON akten (tenant_id);
|
||||
|
||||
ALTER TABLE documents ADD COLUMN IF NOT EXISTS akte_id BIGINT REFERENCES akten(id) ON DELETE SET NULL;
|
||||
Reference in New Issue
Block a user