Release 0.8.0: Cloud-Variante (Supabase, Multi-Studio, Realtime, Web-Deploy)
Rapport ist jetzt dual: lokal (wie bisher) ODER Cloud auf eigenem Supabase-Server. Beide Modi haben dieselben Funktionen, Cloud zusätzlich Multi-User + Live-Sync. Storage-Architektur - src/storage/adapter.js: einheitliche Promise-API, LocalStorage- und SupabaseAdapter - src/storage/migrations.js: applyMigrations als reine Funktion, für beide Backends - Konfig-driven: VITE_SUPABASE_URL im Production-Build → automatisch Cloud-Modus Postgres-Schema (supabase/migrations/0001–0010) - 29 Tabellen, multi-tenant via studio_id + Row-Level-Security - Audit-Spalten (created_by/updated_by/at) + Trigger - Seed-Trigger pro neuem Studio (Rollen, Templates, Absenz-Typen) - Realtime-Publication für Live-Sync - RPCs: ensure_profile, create_studio_with_admin (mit Personen-Sharing), list_studios, load_persons_for_studio, attach_user_to_studio Cloud-Features (App) - BackendChoice.jsx als Erst-Screen «Lokal oder Cloud» - CloudSetup.jsx: 3-Schritt-Wizard für Erst-Einrichtung - Login.jsx: Modus-Switcher + Server-URL + Studio-Dropdown + Passwort-Vergessen - ResetPassword.jsx: empfängt Mail-Link-Klick via PASSWORD_RECOVERY-Event - Realtime: Änderungen zwischen Browsern ohne Reload sichtbar - Settings → System: Cloud-Verbindung, Studio-Switcher, weiteres Studio anlegen - Settings → Team: Mitarbeiter via Email einladen (Admin-Aktion) - Personen-Sharing: bei neuem Studio Personen aus anderen Studios übernehmen - Reload-Resume: studio_id in sessionStorage, kein erneuter Login nötig Web-Deploy - deploy/docker-compose.yml + nginx.conf: dist/ via nginx-Container, Port 8080 - .env.production.example: Build-time Cloud-URL - DEPLOY.md: Anleitung für LAN-only und extern via Nginx Proxy Manager Doku - README.md: Cloud-Variante prominent erklärt - ARCHITECTURE.md: Storage-Adapter, Migrations, neue Views in Risiko-Tabelle - DEPLOY.md: Schritt-für-Schritt für Mac Mini + NPM Version-Bump auf 0.8.0 in package.json, src-tauri/tauri.conf.json, Cargo.toml. Changelog-Entry im App.jsx-Modal (Karim sieht ihn beim ersten Start). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
-- ============================================================================
|
||||
-- RAPPORT — Storage Buckets (Supabase Storage / S3)
|
||||
-- ============================================================================
|
||||
-- Zweck: Datei-Uploads (Quittungen, Studio-Logos) liegen NICHT als Base64 in
|
||||
-- der DB, sondern in Supabase Storage. Die DB hält nur den Pfad
|
||||
-- (z.B. expenses.receipt_url = 'receipts/<studio_id>/2025/abc.pdf').
|
||||
--
|
||||
-- Konvention für Pfade: '<studio_id>/<jahr>/<datei>.<ext>'
|
||||
-- → erste Path-Komponente = studio_id (für RLS)
|
||||
--
|
||||
-- Buckets sind PRIVATE — Zugriff nur über signierte URLs (zeitlich begrenzt).
|
||||
-- ============================================================================
|
||||
|
||||
insert into storage.buckets (id, name, public)
|
||||
values
|
||||
('receipts', 'receipts', false),
|
||||
('logos', 'logos', false)
|
||||
on conflict (id) do nothing;
|
||||
|
||||
-- ────────────────────────────────────────────────────────────────────────────
|
||||
-- RLS-Policies auf storage.objects
|
||||
-- ────────────────────────────────────────────────────────────────────────────
|
||||
-- Prinzip: erste Pfad-Komponente ist studio_id; Zugriff nur wenn Member.
|
||||
-- `(storage.foldername(name))[1]` gibt die erste Pfad-Komponente zurück.
|
||||
|
||||
create policy "rapport_storage_read"
|
||||
on storage.objects for select
|
||||
using (
|
||||
bucket_id in ('receipts','logos')
|
||||
and is_studio_member( (storage.foldername(name))[1]::uuid )
|
||||
);
|
||||
|
||||
create policy "rapport_storage_insert"
|
||||
on storage.objects for insert
|
||||
with check (
|
||||
bucket_id in ('receipts','logos')
|
||||
and is_studio_member( (storage.foldername(name))[1]::uuid )
|
||||
);
|
||||
|
||||
create policy "rapport_storage_update"
|
||||
on storage.objects for update
|
||||
using (
|
||||
bucket_id in ('receipts','logos')
|
||||
and is_studio_member( (storage.foldername(name))[1]::uuid )
|
||||
);
|
||||
|
||||
create policy "rapport_storage_delete"
|
||||
on storage.objects for delete
|
||||
using (
|
||||
bucket_id in ('receipts','logos')
|
||||
and is_studio_member( (storage.foldername(name))[1]::uuid )
|
||||
);
|
||||
|
||||
-- ────────────────────────────────────────────────────────────────────────────
|
||||
-- Hinweise für den Adapter (kein SQL, nur Doku):
|
||||
-- ────────────────────────────────────────────────────────────────────────────
|
||||
-- Upload (Frontend, in SupabaseAdapter):
|
||||
-- const path = `${studioId}/${year}/${uuid()}.${ext}`
|
||||
-- await supabase.storage.from('receipts').upload(path, file)
|
||||
-- // Pfad in expenses.receipt_url speichern
|
||||
--
|
||||
-- Anzeige:
|
||||
-- const { data } = await supabase.storage
|
||||
-- .from('receipts')
|
||||
-- .createSignedUrl(receipt_url, 60) // 60 Sekunden gültig
|
||||
-- // <img src={data.signedUrl} />
|
||||
--
|
||||
-- Migration localStorage → Cloud (im Push-Wizard):
|
||||
-- for jede expense mit receiptData (Base64):
|
||||
-- blob = base64ToBlob(receiptData)
|
||||
-- path = upload(blob)
|
||||
-- row.receipt_url = path; delete row.receiptData
|
||||
-- ============================================================================
|
||||
Reference in New Issue
Block a user