From 72cbca286ae502649f759eef88bdbe011befb381 Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 28 Sep 2026 01:10:06 +0000 Subject: [PATCH] M365-02: 02 sharepoint onedrive dokumentabgleich Migration fuer m365_doc_records (Dokument-Reconciliation-State je Connector-Instanz, getrennte external/nexarch Hash-Staende fuer Konflikterkennung). Co-Authored-By: Claude Sonnet 5 --- .../migrations/0011_m365_doc_records.down.sql | 1 + .../migrations/0011_m365_doc_records.up.sql | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 connect/migrations/0011_m365_doc_records.down.sql create mode 100644 connect/migrations/0011_m365_doc_records.up.sql diff --git a/connect/migrations/0011_m365_doc_records.down.sql b/connect/migrations/0011_m365_doc_records.down.sql new file mode 100644 index 00000000..66c31a2b --- /dev/null +++ b/connect/migrations/0011_m365_doc_records.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS m365_doc_records; diff --git a/connect/migrations/0011_m365_doc_records.up.sql b/connect/migrations/0011_m365_doc_records.up.sql new file mode 100644 index 00000000..3385aca7 --- /dev/null +++ b/connect/migrations/0011_m365_doc_records.up.sql @@ -0,0 +1,26 @@ +-- M365-02: SharePoint/OneDrive-Dokumentabgleich. Getrennte Hash-Staende fuer +-- die zuletzt von Graph gesehene Fassung und die NEXARCH-seitig zuletzt +-- uebernommene Fassung, analog zu master_data_records (ERP-03) -- ein +-- Auseinanderlaufen beider Hashes bei gleichzeitiger externer Aenderung ist +-- ein Konflikt (AC2) statt einer stillen Ueberschreibung. +CREATE TABLE m365_doc_records ( + id BIGSERIAL PRIMARY KEY, + tenant_slug TEXT NOT NULL, + connector_name TEXT NOT NULL, + connector_instance_id TEXT NOT NULL, + external_id TEXT NOT NULL, + name TEXT NOT NULL, + path TEXT NOT NULL, + size_bytes BIGINT NOT NULL, + modified_at TIMESTAMPTZ NOT NULL, + external_hash TEXT NOT NULL, + nexarch_hash TEXT NOT NULL, + conflict BOOLEAN NOT NULL DEFAULT false, + conflict_detected_at TIMESTAMPTZ, + created_at TIMESTAMPTZ NOT NULL DEFAULT now(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), + UNIQUE (tenant_slug, connector_name, connector_instance_id, external_id) +); + +CREATE INDEX m365_doc_records_ref_idx + ON m365_doc_records (tenant_slug, connector_name, connector_instance_id);