Prepare legacy migration for the portal cutover
- detection from legacy category only for scores >= 0.5, without ''/none - category_label + view detection_labeled unify ICU and legacy labels - schema/003 + migrate_legacy --dedupe removes Gundi twins of legacy images (same imei, same size, <= 10 min), archived in image_superseded - migrate_legacy --plan: read-only preview of the migration - Gundi S3 prefix icu/gundi-test/ -> icu/gundi/ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,40 @@ CREATE INDEX IF NOT EXISTS detection_image_confidence_idx
|
||||
CREATE INDEX IF NOT EXISTS detection_category_idx
|
||||
ON remote_cam.detection (category);
|
||||
|
||||
-- Einheitliches Label je Rohkategorie. detection.category bleibt die Rohbezeichnung der
|
||||
-- Quelle (ICU-Gundi: "Deer-Like", Legacy-Klassifikator: "deer"); Auswertungen nutzen das Label.
|
||||
CREATE TABLE IF NOT EXISTS remote_cam.category_label (
|
||||
category text PRIMARY KEY,
|
||||
label text NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO remote_cam.category_label (category, label) VALUES
|
||||
('Deer-Like', 'deer'), ('deer', 'deer'),
|
||||
('person', 'human'), ('human', 'human'),
|
||||
('car', 'machine'), ('machine', 'machine'),
|
||||
('Bird', 'bird'), ('bird', 'bird'),
|
||||
('Fox', 'fox'), ('fox', 'fox'),
|
||||
('Wild Boar', 'wild boar'), ('wild boar', 'wild boar'),
|
||||
('racoon', 'raccoon'), ('raccoon', 'raccoon')
|
||||
ON CONFLICT (category) DO NOTHING;
|
||||
|
||||
-- Ohne Eintrag in category_label gilt die kleingeschriebene Rohbezeichnung.
|
||||
CREATE OR REPLACE VIEW remote_cam.detection_labeled AS
|
||||
SELECT d.*, COALESCE(cl.label, lower(d.category)) AS label
|
||||
FROM remote_cam.detection d
|
||||
LEFT JOIN remote_cam.category_label cl ON cl.category = d.category;
|
||||
|
||||
-- Gundi-Bilder, die waehrend des Parallelbetriebs auch ueber den Legacy-Pfad kamen und
|
||||
-- zugunsten des Legacy-Zwillings (traegt die KI-Ergebnisse) entfernt wurden. Haelt die
|
||||
-- geloeschte image-Zeile samt Detections fuer Nachvollziehbarkeit und Rollback.
|
||||
CREATE TABLE IF NOT EXISTS remote_cam.image_superseded (
|
||||
image_uuid uuid PRIMARY KEY,
|
||||
superseded_by uuid NOT NULL,
|
||||
removed_at timestamptz NOT NULL DEFAULT now(),
|
||||
image_row jsonb NOT NULL,
|
||||
detections jsonb
|
||||
);
|
||||
|
||||
-- Transportschicht des Push-Pfads: Rohevents + Zustandsmaschine.
|
||||
CREATE TABLE IF NOT EXISTS remote_cam.gundi_inbox (
|
||||
object_id uuid PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user