diff --git a/.gitignore b/.gitignore
index 5bb36d0..bb3375d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,5 @@ dist/
coverage/
*.tsbuildinfo
.DS_Store
+test-results/
+playwright-report/
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..12704ed
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,77 @@
+# AGENTS.md — Projektregeln für das Immich-Redaktions-Portal
+
+Technisches Wissen (Immich-API-Eigenheiten, Migrationen, Deployment, Auth-Härtung)
+steht in `AI_MEMORY.md`. Diese Datei hier regelt den Arbeitsablauf.
+
+## Versionierung & Versionshinweise (PFLICHT bei jeder Änderung)
+
+Bei jedem neuen Feature, jeder Änderung und jedem Fix im Portal:
+
+1. **Versionshinweise aktualisieren** — für Admins UND Redaktionen (Zielgruppen
+ `admin`, `editorial`, `both`). Pflege im Portal unter `/admin/versionen`
+ (Tabelle `release_notes`), für Deployments zusätzlich als Seed in der
+ jeweiligen Drizzle-Migration (`ON CONFLICT DO NOTHING`).
+2. **Versionsnummer fortführen** — nie neu starten, nie überspringen.
+ Größenordnung nach Umfang der Änderung:
+ - kleiner Fix / Politur: Patch, z. B. `2.1.1`
+ - neues Feature / spürbare Erweiterung: Minor, z. B. `2.2`
+ - großer Umbau / breaking: Major, z. B. `3.0`
+3. **Nummer vorschlagen und absegnen lassen** — vor der Umsetzung eine konkrete
+ Nummer vorschlagen; der Nutzer approved sie oder nennt eine eigene. Ohne
+ Antwort keine eigenmächtige Major-/Minor-Sprünge.
+4. Hinweis-Texte kurz und konkret auf Deutsch, aus Nutzersicht formuliert
+ (was ist neu, wo findet man es). Keine Marketing-Floskeln.
+
+Aktueller Stand: siehe neueste Einträge in `release_notes` (Basis `2.0.0`,
+Kalender/Selbstbedienung/Sortierung/Beschreibung: `2.1.0`,
+Dateiname-Suche: `2.1.1`, Statistik/Collab/Rechnungsversand: `2.2.0`).
+
+## Sicherheit (bei jeder Änderung mitprüfen)
+
+- Album-Zugriff läuft ausschließlich über `album_grants` (Service
+ `albumGrantService`). Neue Zugriffswege nur mit Audit-Event und
+ Admin-Entzugsmöglichkeit; Selbstbedienung nur über Kalender-Events
+ (`source: 'self_service'`), Auto-Regeln stehen über dem Kalender.
+- Niemals `asset.albums` für Berechtigungen vertrauen (siehe AI_MEMORY §2).
+- Nutzertexte (Immich-Beschreibungen, Albumnamen, Hinweise) immer als
+ React-Text rendern, nie als HTML (`dangerouslySetInnerHTML` ist tabu).
+- Neue mutierende Endpoints/Actions: Session-Guard (`requireAdmin` /
+ `requireActiveEditorial`) und bei Missbrauchspotenzial Rate-Limit
+ (`src/modules/security/rate-limit.ts`).
+- Lösch-Actions mit Folgewirkung (z. B. Kalender-Event löschen entzieht
+ Selbstzugriffe) im UI bestätigen lassen.
+
+## UI & Design
+
+- Vor UI-Arbeit `~/.claude/DESIGN.md` lesen; das Portal ist auf **SakaniUI**
+ aufgebaut (`@sakaniui/react`). Server Components importieren Sakani über
+ die Client-Grenze `src/components/ui/sakani.tsx` (Card, StatCard, Badge,
+ Button, Checkbox, Input, FormSelect, DataTable, BarChart, EmptyState, …).
+ Projekt-Tokens stehen in `src/app/globals.css` (alte Tailwind-Namen wie
+ `bg-card`/`border-border` sind auf Sakani-Tokens gemappt). Beide Themes
+ (hell/dunkel) prüfen.
+- Navigation lebt in `src/components/layout/app-shell.tsx` (AREAS), nicht in
+ den Layouts. Release-Popup: `src/components/layout/release-notes.tsx`
+ (RELEASE.version bei jedem Release bumpen); die pflegbare Historie liegt
+ in `release_notes` (/admin/versionen, /redaktion/neuigkeiten).
+- Header-Logo: `/brand/logo-black.png` / `logo-white.png` (AppShell/PublicShell).
+ Originale bleiben für Wasserzeichen/E-Mail/PDF unverändert.
+
+## Tests & Verifikation
+
+- `pnpm typecheck`, `pnpm lint`, `pnpm test` (Vitest) vor Abschluss.
+- `tests/db/*` brauchen Docker (Testcontainers); ohne Docker laufen nur die
+ Unit-Tests — das im Abschlussbericht offen benennen.
+- Migrationen: `drizzle-kit generate`, nie manuellSnapshots editieren;
+ Seed-Daten idempotent anhängen. Deploy-Reihenfolge siehe AI_MEMORY §8
+ (`docker compose --profile ops build`!).
+
+
+
+## This is NOT the Next.js you know
+
+This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
+
+This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
+
+
diff --git a/AI_MEMORY.md b/AI_MEMORY.md
index c893e5d..3c8b5b5 100644
--- a/AI_MEMORY.md
+++ b/AI_MEMORY.md
@@ -31,7 +31,8 @@ Redaktionen können Bilder durchsuchen, einen Leuchtkasten verwenden, Bilder her
- Diese Logik befindet sich in `src/modules/editorials/service.ts` unter `hardDeleteEditorial`.
## 4. UI & Styling Quirks
-- **Logo Skalierung:** Das Hauptlogo (`logo-black.png` / `logo-white.png`) darf im ``-Tag **keine** harten `width` und `height`-Attribute (z.B. `1000`) haben, sonst wird das Layout in den Page-Headern gesprengt. Die Skalierung wird dynamisch in `src/app/globals.css` über `.brand-logo` (`max-height: 2.5rem; width: min(10rem, 35vw); object-fit: contain`) geregelt.
+- **Logo Skalierung:** Das Hauptlogo (`logo-black.png` / `logo-white.png`) darf im `
`-Tag **keine** harten `width` und `height`-Attribute (z.B. `1000`) haben, sonst wird das Layout in den Page-Headern gesprengt. Die Skalierung wird in `src/app/globals.css` über `.brand-logo` geregelt (height-led: `height: 2.25rem; width: auto; max-width: min(12rem, 40vw)` plus `aspect-ratio` je Variante).
+- **Header-Logo-Varianten (Stand 2026-11, v2.1):** Die Originale haben riesige transparente/weiße Ränder (`logo-black.png` ist 1000×1000 mit weißem 900×900-Block, Motiv nur ~776×417). Unter der alten `width`+`max-height`-Letterboxung schrumpfte das Motiv auf ~17px und war praktisch unsichtbar. Der Header (`BrandLogo`) nutzt deshalb **beschnittene Varianten** `public/brand/logo-black-header.png` (800×441, weißer Grund) und `logo-white-header.png` (194×104, transparent). Die Originale bleiben unverändert für Wasserzeichen (`thumbnail-handler.ts`), E-Mails und PDF. Nie die Originale für den Header verwenden, nie die Header-Varianten fürs Wasserzeichen (Skalierung dort = 50% Bildbreite).
- **E-Mails & Dark Mode:** Die E-Mail-Templates befinden sich in `src/modules/email/service.ts` und `src/modules/mail/mailer.ts`. Beide unterstützen nativ Dark Mode via CSS (`@media (prefers-color-scheme: dark)`). Im Dark Mode wird `logo-black.png` durch `logo-white.png` ausgetauscht. Die Layouts sind responsiv (`max-width: 100%` für Bilder) aufgebaut, sodass sie auch auf mobilen Geräten gut lesbar bleiben.
## 5. Laufende Prozesse & Downloads
- **Bulk Downloads:** Zip-Downloads (`archiver`) von mehreren Bildern nutzen Node.js Streams (`PassThrough`). Da Next.js die Response direkt an den Browser streamt, muss sichergestellt werden, dass der Stream nicht blockiert wird (`Readable.toWeb`). Siehe `src/app/api/lightbox/bulk-download/route.ts`.
@@ -62,3 +63,20 @@ Redaktionen können Bilder durchsuchen, einen Leuchtkasten verwenden, Bilder her
- **Diagnose-Kette, wenn Migrationen „nicht funktionieren":** (1) Server-Checkout prüfen: `git log --oneline -1` + `ls drizzle/`. (2) Image-Inhalt prüfen: `docker compose run --rm --no-deps migrate ls /app/drizzle` — weichen Checkout und Image ab, war der Build nicht/nicht für das Profil gelaufen (Falle oben). (3) DB-Wasserstand prüfen: `SELECT id, hash, created_at FROM drizzle.__drizzle_migrations ORDER BY id;` — der Drizzle-Migrator wendet nur Journal-Einträge mit `when` > max(`created_at`) an. PROD hatte 6 Zeilen / Wasserstand `1786379282947` (= alt-0005); die Baseline (`when=1786299825190`, bewusst alt-0000-Timestamp, siehe Abschnitt 7) liegt darunter und wird korrekt übersprungen — nur tatsächlich neue Migrationen (z. B. `0001_add_announcements`, `when=1789139950413`) laufen. Ein Exit 1 ohne sichtbare Fehlerzeile bedeutet fast immer: altes Image versucht alte Migrationen erneut → „already exists".
- **Fehlerbild „Verbindung unterbrochen / Diese Seite konnte nicht geladen werden":** Das ist das eigene Error-Boundary (`src/app/error.tsx`) für Server-Fehler beim Rendern — die App läuft also, aber eine Seite wirft. Nach jedem Deploy zuerst `docker compose logs --tail 50 portal-app` lesen. Typischer Kandidat: neue App-Version fragt eine frische Migration-Tabelle ab, die (wegen der Build-Falle oben) noch nicht existiert → Migration nachholen genügt, App muss dafür nicht neu gestartet werden.
- **Git-Remotes:** `origin` ist SSH (`git@gitlab.tonhaeuser.cloud:leon/…`) — der `git`-User ist der feste GitLab-SSH-Systembenutzer, **nicht** der Account-Name; Auth läuft über den SSH-Key des Kontos. `Permission denied (publickey)` = Key fehlt im GitLab-Konto (Preferences → SSH Keys), nicht falscher Username in der URL. Ersatz-Remote `origin-https` (HTTPS + Passwort/PAT) existiert für den Notfall; Push-Status prüfen mit `git status -sb` („ahead" = noch nicht gepusht — dann kam auf dem Server auch nichts an, und `git pull` meldet fälschlich „Already up to date").
+
+## 9. Kalender, Selbstbedienung & Versionshinweise (Stand 2026-11, v2.1)
+- **Versionierung ist Projektpflicht:** `CLAUDE.md` verlangt bei JEDER Änderung aktualisierte Versionshinweise für Admins und Redaktionen plus fortlaufende Nummer (Patch/Minor/Major je Umfang). Nummer wird dem Nutzer vorgeschlagen und von ihm approved. Pflege: `/admin/versionen` (Tabelle `release_notes`, unique je Version+Zielgruppe), Anzeige für Redaktionen: `/redaktion/neuigkeiten`. Migration `0002` seedet idempotent `2.0.0` (Basis) und `2.1.0`.
+- **Kalender (`calendar_events`):** Admin legt Termine an (`/admin/kalender`, Titel + Datum + optional explizite Album-ID). Album-Verknüpfung passiert automatisch per **exaktem Namens-Match**: Album heißt `{Titel}` oder `{Titel} | {TT.MM.JJJJ}` (Datum des Termins) — siehe `matchEventAlbum` in `src/modules/calendar/event-albums.ts`. Albumnamen des Fotografen folgen genau diesem Schema. Private Alben matchen nie, solange der Admin ihren Namen nicht bewusst als Termin-Titel wählt (die Trust Boundary ist der admin-erstellte Termin).
+- **Selbstbedienung (`album_grants.source`):** Redaktionen können das verknüpfte Album eines Termins unter `/redaktion/kalender` selbst freischalten (`selfGrantAlbum`, Rate-Limit `calendarSelfGrantPolicy`, Audit `album_self_granted`, `source: 'self_service'`). Grants ohne Kalender-Termin sind nicht self-servicebar. **Auto-Regeln stehen über dem Kalender:** `source: 'auto_rule'` und `admin`-Grants werden nie vom Kalender angetastet. Löscht der Admin einen Termin, entzieht `revokeSelfServiceGrantsForAlbum` NUR die `self_service`-Grants dieses Albums (Audit `album_revoked` mit `reason: calendar_event_deleted`).
+- **RSVP (`event_responses`):** Je Termin und Redaktion genau eine Zeile (`attending`/`not_attending`, Upsert). Admin sieht Zusagen/Absagen als Chips je Termin. Audit `event_response_recorded` (actorType `editorial`).
+- **Sichtbarkeitsfenster Redaktion:** Termine ab `heute - 30 Tage` (`CALENDAR_PAST_DAYS`), kommende aufsteigend, vergangene absteigend. Immich-Ausfall degradiert nur die Album-Verknüpfung (`immichUnavailable`), Termine/RSVP funktionieren weiter.
+- **Sortierung Fotos:** `sortierung=neueste|aelteste` (Default neueste) in Album-Suche UND Cross-Alben-Suche; `sortPhotos` in `src/modules/albums/filter.ts` sortiert das gesamte geholte Set VOR dem Paginieren (auch über gemergte Per-Album-Seiten). Pagination-Links (`pageHref`, `globalPageHref`) führen den Parameter mit, ebenso Format/Jahr.
+- **Bildbeschreibung:** Immich liefert sie in `exifInfo.description` (`withExif: true` war schon aktiv). Schema/Typ erweitert, Anzeige in der Lightbox (`PhotoLightbox` in `photo-gallery.tsx`, Klasse `.lightbox-description`, scrollbar bei >24vh). Nur React-Text, kein HTML.
+
+## 10. Dateiname-Suche, Collab, Rechnungsversand & Statistiken (Stand 2026-11, v2.2)
+- **Dateiname-Suche (2.1.1):** Immich verknüpft Metadaten-Filter mit UND. Deshalb sucht `searchAlbumMerged` (`src/modules/albums/catalog.ts`) bei Query je Album zweimal (description ODER originalFileName) und merged dedupliziert. Merkzettel-Deep-Links (`?suche={dateiname}`) funktionieren damit. Gleiche Grant-Prüfung wie bisher.
+- **Collab (2.2.0):** `editorial_accounts.collab_enabled` (Admin-Toggle unter `/admin/redaktionen/[id]`, Audit `editorial_collab_updated`). Nur freigeschaltete Redaktionen sehen die Checkbox „Collab-Nutzung (kostenfrei)" im UsageDialog und im Merkzettel-Bulk-Download. `usages.collab` + `priceCents = 0`; Collab zählt NICHT gegen das Flatrate-Limit (`eq(usages.collab, false)` im Limit-Count). Fehler `COLLAB_NOT_ENABLED` → 403. Admin kann offene/wiedereröffnete Nutzungen unter Abrechnungen nachträglich markieren/entmarken (`POST /api/usages/[usageId]/collab`, Preis 0 ↔ currentPriceCents, Audit `usage_collab_updated`). Nutzungsnachweis-PDF zeigt `(Collab)` hinter dem Zweck, `billing_report_items.collab` als Snapshot.
+- **Fingerprint-Kompatibilität (WICHTIG):** `requestFingerprint` für `new_usage` DARF nicht um neue Felder (z. B. collab) erweitert werden — die historischen Migrationen 0001/0002 rekonstruieren Legacy-Fingerprints aus der alten Payload-Form. Tests in `tests/db/accounting-migration.test.ts` prüfen das.
+- **Rechnungsversand (2.2.0):** Finalisieren verschickt KEINE E-Mail mehr (Nutzungsnachweis dient der Prüfung; Korrekturen via Collab-Toggle oder Storno + Neu-Finalisierung). Admin lädt die Rechnungs-PDF unter Abrechnungen hoch (`POST /api/billing-reports/[reportId]/invoice`, multipart, %PDF-Magic, max 20 MB, Rate-Limit `invoiceUploadPolicy`). Der Upload speichert (`invoice_pdf`, `invoice_pdf_sha256`, …) und sendet automatisch GEBÜNDELT Rechnung + Nutzungsnachweis (`emailService.sendInvoiceBundle`, Vorlage `invoice-message.ts`). Status `invoice_email_status` (not_sent/sent/failed) + `invoice_email_sent_at`/`invoice_email_error`; „Erneut senden" via `POST …/invoice/resend`, Download via `GET …/invoice`. Audit: `invoice_uploaded`, `invoice_email_sent`, `invoice_email_failed`.
+- **Activity-Tracking (2.2.0):** `activity_events` (album_view/search/lightbox_view) nur für Browsing; Downloads bleiben in `download_events`. Server-Hooks in den Albumseiten, Lightbox-Beacon `POST /api/activity` (nur lightbox_view). `recordActivity` ist fire-and-forget: validiert, rate-limited (`activityPolicy` 240/60s), schluckt alle Fehler. Statistikseite `/admin/statistiken` (`src/modules/stats/queries.ts`, Zeitraum 7/30/90 Tage via `zeitraum`): KPI-Karten mit Trend-Pills (Vorperiode), Recharts Area/Bar (lazy, ssr:false, Theme-Farben), Top-Redaktionen/Alben, offene Umsätze, letzte Aktivitäten. SakaniUI-Elemente: Pill-Segmented-Control, Uppercase-Muted-Labels, Tabular-Nums, Hover-Shadow.
+- **Lokale Verifikation (tmp/, gitignored):** Dev-Server `NEXT_DISABLE_TURBOPACK=1 next dev` (Port 3000), Mock-Immich :2283 (inkl. `/original`), Mock-SMTP :587 (`tmp/mock-smtp.mjs`, loggt nach `tmp/mock-smtp.log`), DB-Container `portal-clickthrough-db` :5433. BetterAuth-Sign-In-Limit 5/15min liegt IM SPEICHER des Dev-Servers — vor jedem Click-Through-Lauf Dev-Server neu starten; die Spec cached Session-Cookies nach dem ersten Login (`loginCached`). `tmp/dev-seed.ts` ist idempotent: User per E-Mail auflösen (signUp mit existierender E-Mail liefert Phantom-User ohne Persistenz!), 2FA-Setup überspringen wenn verified, Rechnungsadresse anlegen. Click-Through: `node_modules/.bin/playwright test --config tmp/playwright.config.ts` (7 Tests, Reset via beforeAll, FK-Reihenfolge beachten: items → download_events → usages → billing_reports).
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 0000000..43c994c
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1 @@
+@AGENTS.md
diff --git a/drizzle/0002_release_notes_calendar.sql b/drizzle/0002_release_notes_calendar.sql
new file mode 100644
index 0000000..5ac2c48
--- /dev/null
+++ b/drizzle/0002_release_notes_calendar.sql
@@ -0,0 +1,45 @@
+CREATE TABLE "calendar_events" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "title" text NOT NULL,
+ "event_date" date NOT NULL,
+ "immich_album_id" text,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "created_by_user_id" uuid
+);
+--> statement-breakpoint
+CREATE TABLE "event_responses" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "event_id" uuid NOT NULL,
+ "editorial_account_id" uuid NOT NULL,
+ "status" text NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "event_responses_status_check" CHECK ("event_responses"."status" in ('attending', 'not_attending'))
+);
+--> statement-breakpoint
+CREATE TABLE "release_notes" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "version" text NOT NULL,
+ "audience" text DEFAULT 'both' NOT NULL,
+ "body" text NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "created_by_user_id" uuid,
+ CONSTRAINT "release_notes_audience_check" CHECK ("release_notes"."audience" in ('admin', 'editorial', 'both')),
+ CONSTRAINT "release_notes_version_check" CHECK ("release_notes"."version" ~ '^[0-9]+\.[0-9]+(\.[0-9]+)?$')
+);
+--> statement-breakpoint
+ALTER TABLE "album_grants" ADD COLUMN "source" text DEFAULT 'admin' NOT NULL;--> statement-breakpoint
+ALTER TABLE "calendar_events" ADD CONSTRAINT "calendar_events_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "event_responses" ADD CONSTRAINT "event_responses_event_id_calendar_events_id_fk" FOREIGN KEY ("event_id") REFERENCES "public"."calendar_events"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "event_responses" ADD CONSTRAINT "event_responses_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "release_notes" ADD CONSTRAINT "release_notes_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
+CREATE UNIQUE INDEX "event_responses_event_editorial_unique" ON "event_responses" USING btree ("event_id","editorial_account_id");--> statement-breakpoint
+CREATE UNIQUE INDEX "release_notes_version_audience_unique" ON "release_notes" USING btree ("version","audience");--> statement-breakpoint
+ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_source_check" CHECK ("album_grants"."source" in ('admin', 'auto_rule', 'self_service'));--> statement-breakpoint
+-- Seed the version notes: 2.0.0 documents the existing portal as the baseline,
+-- 2.1.0 documents this release. Idempotent so re-runs never duplicate rows.
+INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id")
+VALUES
+ ('2.0.0', 'both', 'Basisversion des Redaktionsportals: Albumfreigaben mit automatischen Regeln, Suche über alle Alben, Merkzettel, Wasserzeichen-Vorschauen, lizenzierte Downloads mit automatischer Abrechnung, Hinweise des Fotografen und Zwei-Faktor-Schutz für Admins.', NULL),
+ ('2.1.0', 'editorial', 'Neu in 2.1: Fotos lassen sich in der Album-Suche und in der Suche über alle Alben nach ältesten und neuesten sortieren. Die Bildbeschreibung wird jetzt in der Großansicht angezeigt. Der neue Kalender zeigt kommende Termine, Sie können je Termin zurückmelden, ob Sie da sind. Event-Alben aus dem Kalender können Sie selbst freischalten und sofort öffnen. Das Logo im Kopfbereich ist wieder sichtbar.', NULL),
+ ('2.1.0', 'admin', 'Neu in 2.1: Kalender unter /admin/kalender (Termine anlegen, Alben verknüpfen, Zusagen der Redaktionen einsehen). Redaktionen schalten Kalender-Alben selbst frei, jeder Selbstzugriff wird im Audit protokolliert und lässt sich unter Alben entziehen. Versionshinweise werden unter /admin/versionen gepflegt. Sortierung und Bildbeschreibung in der Redaktionssuche, Logo im Kopfbereich korrigiert.', NULL)
+ON CONFLICT ("version", "audience") DO NOTHING;
\ No newline at end of file
diff --git a/drizzle/0003_collab_invoice_activity.sql b/drizzle/0003_collab_invoice_activity.sql
new file mode 100644
index 0000000..ef272cf
--- /dev/null
+++ b/drizzle/0003_collab_invoice_activity.sql
@@ -0,0 +1,35 @@
+CREATE TABLE "activity_events" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "editorial_account_id" uuid NOT NULL,
+ "event_type" text NOT NULL,
+ "immich_album_id" text,
+ "immich_asset_id" text,
+ "query" text,
+ "occurred_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "activity_events_event_type_check" CHECK ("activity_events"."event_type" in ('album_view', 'search', 'lightbox_view'))
+);
+--> statement-breakpoint
+ALTER TABLE "billing_report_items" ADD COLUMN "collab" boolean DEFAULT false NOT NULL;--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD COLUMN "invoice_pdf" "bytea";--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD COLUMN "invoice_pdf_sha256" varchar(64);--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD COLUMN "invoice_pdf_filename" text;--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD COLUMN "invoice_uploaded_at" timestamp with time zone;--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD COLUMN "invoice_email_status" text DEFAULT 'not_sent' NOT NULL;--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD COLUMN "invoice_email_sent_at" timestamp with time zone;--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD COLUMN "invoice_email_error" text;--> statement-breakpoint
+ALTER TABLE "editorial_accounts" ADD COLUMN "collab_enabled" boolean DEFAULT false NOT NULL;--> statement-breakpoint
+ALTER TABLE "usages" ADD COLUMN "collab" boolean DEFAULT false NOT NULL;--> statement-breakpoint
+ALTER TABLE "activity_events" ADD CONSTRAINT "activity_events_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "activity_events_occurred_at_idx" ON "activity_events" USING btree ("occurred_at" DESC NULLS LAST);--> statement-breakpoint
+CREATE INDEX "activity_events_editorial_occurred_idx" ON "activity_events" USING btree ("editorial_account_id","occurred_at" DESC NULLS LAST);--> statement-breakpoint
+CREATE INDEX "activity_events_type_occurred_idx" ON "activity_events" USING btree ("event_type","occurred_at" DESC NULLS LAST);--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD CONSTRAINT "billing_reports_invoice_pdf_sha256_hex_check" CHECK ("billing_reports"."invoice_pdf_sha256" IS NULL OR "billing_reports"."invoice_pdf_sha256" ~ '^[0-9a-f]{64}$');--> statement-breakpoint
+ALTER TABLE "billing_reports" ADD CONSTRAINT "billing_reports_invoice_email_status_check" CHECK ("billing_reports"."invoice_email_status" in ('not_sent', 'sent', 'failed'));
+-- Seed the version notes for this release chain. Idempotent so re-runs never
+-- duplicate rows (unique on version + audience).
+INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id")
+VALUES
+ ('2.1.1', 'editorial', 'Die Suche in Alben und über alle Alben findet jetzt auch Dateinamen. Links vom Merkzettel führen damit direkt zum richtigen Bild.', NULL),
+ ('2.2.0', 'admin', 'Neu in 2.2: Statistik-Seite unter /admin/statistiken mit Downloads, Datenmenge, Aufrufen, Suchen, Umsatz und Collab-Nutzungen. Collab-Nutzung je Redaktion unter Redaktionen freischalten; Collab-Positionen erscheinen mit 0,00 € in der Abrechnung und lassen sich dort vor dem Versand korrigieren. Rechnungen: PDF je Abrechnung unter Abrechnungen hochladen, danach geht die Rechnung gebündelt mit dem Nutzungsnachweis automatisch per E-Mail an die Redaktion. Der Nutzungsnachweis wird beim Finalisieren nicht mehr automatisch verschickt.', NULL),
+ ('2.2.0', 'editorial', 'Neu in 2.2: Wenn Ihre Redaktion für Collab freigeschaltet ist, können Sie beim Download die Option Collab (kostenfrei) wählen, auch für mehrere Bilder vom Merkzettel. Rechnung und Nutzungsnachweis kommen gebündelt per E-Mail, sobald die Rechnung vorliegt.', NULL)
+ON CONFLICT ("version", "audience") DO NOTHING;
\ No newline at end of file
diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json
new file mode 100644
index 0000000..805ec5a
--- /dev/null
+++ b/drizzle/meta/0002_snapshot.json
@@ -0,0 +1,2285 @@
+{
+ "id": "f708aa98-0633-4a85-9d4b-879142f89a62",
+ "prevId": "b98d41ae-a5a1-4e1c-bb31-99cc096528a0",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.album_grants": {
+ "name": "album_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_album_id": {
+ "name": "immich_album_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_at": {
+ "name": "granted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "granted_by_user_id": {
+ "name": "granted_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'admin'"
+ }
+ },
+ "indexes": {
+ "album_grants_editorial_account_id_idx": {
+ "name": "album_grants_editorial_account_id_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "album_grants_immich_album_id_idx": {
+ "name": "album_grants_immich_album_id_idx",
+ "columns": [
+ {
+ "expression": "immich_album_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "album_grants_editorial_active_album_unique": {
+ "name": "album_grants_editorial_active_album_unique",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"immich_album_id\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"album_grants\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "album_grants_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "album_grants_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "album_grants",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "album_grants_granted_by_user_id_user_id_fk": {
+ "name": "album_grants_granted_by_user_id_user_id_fk",
+ "tableFrom": "album_grants",
+ "tableTo": "user",
+ "columnsFrom": [
+ "granted_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "album_grants_immich_album_id_uuid_check": {
+ "name": "album_grants_immich_album_id_uuid_check",
+ "value": "\"album_grants\".\"immich_album_id\" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ },
+ "album_grants_source_check": {
+ "name": "album_grants_source_check",
+ "value": "\"album_grants\".\"source\" in ('admin', 'auto_rule', 'self_service')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.announcements": {
+ "name": "announcements",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_date": {
+ "name": "event_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "announcements_created_by_user_id_user_id_fk": {
+ "name": "announcements_created_by_user_id_user_id_fk",
+ "tableFrom": "announcements",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.audit_events": {
+ "name": "audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'system'"
+ },
+ "entity_type": {
+ "name": "entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_values": {
+ "name": "previous_values",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_values": {
+ "name": "new_values",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "audit_events_actor_user_id_user_id_fk": {
+ "name": "audit_events_actor_user_id_user_id_fk",
+ "tableFrom": "audit_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.two_factor": {
+ "name": "two_factor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "backup_codes": {
+ "name": "backup_codes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verified": {
+ "name": "verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "failed_verification_count": {
+ "name": "failed_verification_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "locked_until": {
+ "name": "locked_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "two_factor_user_id_user_id_fk": {
+ "name": "two_factor_user_id_user_id_fk",
+ "tableFrom": "two_factor",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "two_factor_user_id_unique": {
+ "name": "two_factor_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "portal_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'EDITORIAL'"
+ },
+ "two_factor_enabled": {
+ "name": "two_factor_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.album_auto_rules": {
+ "name": "album_auto_rules",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "album_auto_rules_editorial_account_id_keyword_idx": {
+ "name": "album_auto_rules_editorial_account_id_keyword_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"keyword\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "album_auto_rules_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "album_auto_rules_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "album_auto_rules",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "album_auto_rules_created_by_user_id_user_id_fk": {
+ "name": "album_auto_rules_created_by_user_id_user_id_fk",
+ "tableFrom": "album_auto_rules",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_report_items": {
+ "name": "billing_report_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "billing_report_id": {
+ "name": "billing_report_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "usage_id": {
+ "name": "usage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_asset_id_snapshot": {
+ "name": "immich_asset_id_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename_snapshot": {
+ "name": "filename_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "album_name_snapshot": {
+ "name": "album_name_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purpose_snapshot": {
+ "name": "purpose_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_reference_snapshot": {
+ "name": "internal_reference_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_cents": {
+ "name": "price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "billing_report_items_report_usage_unique": {
+ "name": "billing_report_items_report_usage_unique",
+ "columns": [
+ {
+ "expression": "billing_report_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "billing_report_items_billing_report_id_billing_reports_id_fk": {
+ "name": "billing_report_items_billing_report_id_billing_reports_id_fk",
+ "tableFrom": "billing_report_items",
+ "tableTo": "billing_reports",
+ "columnsFrom": [
+ "billing_report_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_report_items_usage_id_usages_id_fk": {
+ "name": "billing_report_items_usage_id_usages_id_fk",
+ "tableFrom": "billing_report_items",
+ "tableTo": "usages",
+ "columnsFrom": [
+ "usage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_reports": {
+ "name": "billing_reports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "report_number": {
+ "name": "report_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_starts_at": {
+ "name": "period_starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_ends_at": {
+ "name": "period_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_address_snapshot": {
+ "name": "billing_address_snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invoice_number": {
+ "name": "invoice_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "net_total_cents": {
+ "name": "net_total_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flatrate_cents_snapshot": {
+ "name": "flatrate_cents_snapshot",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "report_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "pdf": {
+ "name": "pdf",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pdf_sha256": {
+ "name": "pdf_sha256",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "finalized_at": {
+ "name": "finalized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled_at": {
+ "name": "cancelled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_reason": {
+ "name": "cancellation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled_by_user_id": {
+ "name": "cancelled_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "billing_reports_report_number_unique": {
+ "name": "billing_reports_report_number_unique",
+ "columns": [
+ {
+ "expression": "report_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "billing_reports_invoice_number_unique": {
+ "name": "billing_reports_invoice_number_unique",
+ "columns": [
+ {
+ "expression": "invoice_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "billing_reports_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "billing_reports",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_reports_created_by_user_id_user_id_fk": {
+ "name": "billing_reports_created_by_user_id_user_id_fk",
+ "tableFrom": "billing_reports",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_reports_cancelled_by_user_id_user_id_fk": {
+ "name": "billing_reports_cancelled_by_user_id_user_id_fk",
+ "tableFrom": "billing_reports",
+ "tableTo": "user",
+ "columnsFrom": [
+ "cancelled_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "billing_reports_pdf_sha256_hex_check": {
+ "name": "billing_reports_pdf_sha256_hex_check",
+ "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'"
+ },
+ "billing_reports_final_pdf_check": {
+ "name": "billing_reports_final_pdf_check",
+ "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.calendar_events": {
+ "name": "calendar_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_date": {
+ "name": "event_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_album_id": {
+ "name": "immich_album_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "calendar_events_created_by_user_id_user_id_fk": {
+ "name": "calendar_events_created_by_user_id_user_id_fk",
+ "tableFrom": "calendar_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.event_responses": {
+ "name": "event_responses",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "event_responses_event_editorial_unique": {
+ "name": "event_responses_event_editorial_unique",
+ "columns": [
+ {
+ "expression": "event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "event_responses_event_id_calendar_events_id_fk": {
+ "name": "event_responses_event_id_calendar_events_id_fk",
+ "tableFrom": "event_responses",
+ "tableTo": "calendar_events",
+ "columnsFrom": [
+ "event_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "event_responses_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "event_responses_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "event_responses",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "event_responses_status_check": {
+ "name": "event_responses_status_check",
+ "value": "\"event_responses\".\"status\" in ('attending', 'not_attending')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.billing_address_versions": {
+ "name": "billing_address_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "contact_name": {
+ "name": "contact_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postal_code": {
+ "name": "postal_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "city": {
+ "name": "city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valid_from": {
+ "name": "valid_from",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "superseded_by_id": {
+ "name": "superseded_by_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "billing_address_versions",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": {
+ "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk",
+ "tableFrom": "billing_address_versions",
+ "tableTo": "billing_address_versions",
+ "columnsFrom": [
+ "superseded_by_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_address_versions_created_by_user_id_user_id_fk": {
+ "name": "billing_address_versions_created_by_user_id_user_id_fk",
+ "tableFrom": "billing_address_versions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.editorial_accounts": {
+ "name": "editorial_accounts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "contact_name": {
+ "name": "contact_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "login_email": {
+ "name": "login_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "account_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending_email'"
+ },
+ "current_price_cents": {
+ "name": "current_price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flatrate_active": {
+ "name": "flatrate_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "flatrate_price_cents": {
+ "name": "flatrate_price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flatrate_asset_limit": {
+ "name": "flatrate_asset_limit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "approval_notice_status": {
+ "name": "approval_notice_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'not_requested'"
+ },
+ "current_billing_address_version_id": {
+ "name": "current_billing_address_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_verified_at": {
+ "name": "email_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_terms_version": {
+ "name": "accepted_terms_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_terms_at": {
+ "name": "accepted_terms_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "privacy_acknowledged_at": {
+ "name": "privacy_acknowledged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_by_user_id": {
+ "name": "archived_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "editorial_accounts_user_id_user_id_fk": {
+ "name": "editorial_accounts_user_id_user_id_fk",
+ "tableFrom": "editorial_accounts",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": {
+ "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk",
+ "tableFrom": "editorial_accounts",
+ "tableTo": "billing_address_versions",
+ "columnsFrom": [
+ "current_billing_address_version_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "editorial_accounts_archived_by_user_id_user_id_fk": {
+ "name": "editorial_accounts_archived_by_user_id_user_id_fk",
+ "tableFrom": "editorial_accounts",
+ "tableTo": "user",
+ "columnsFrom": [
+ "archived_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "editorial_accounts_user_id_unique": {
+ "name": "editorial_accounts_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "editorial_accounts_login_email_unique": {
+ "name": "editorial_accounts_login_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "login_email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.lightbox_items": {
+ "name": "lightbox_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "asset_id": {
+ "name": "asset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "added_at": {
+ "name": "added_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "lightbox_items_editorial_asset_idx": {
+ "name": "lightbox_items_editorial_asset_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "asset_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "lightbox_items_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "lightbox_items_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "lightbox_items",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rate_limits": {
+ "name": "rate_limits",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_boundary": {
+ "name": "window_boundary",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "rate_limits_key_window_boundary_pk": {
+ "name": "rate_limits_key_window_boundary_pk",
+ "columns": [
+ "key",
+ "window_boundary"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.release_notes": {
+ "name": "release_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "version": {
+ "name": "version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "audience": {
+ "name": "audience",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'both'"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "release_notes_version_audience_unique": {
+ "name": "release_notes_version_audience_unique",
+ "columns": [
+ {
+ "expression": "version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "audience",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "release_notes_created_by_user_id_user_id_fk": {
+ "name": "release_notes_created_by_user_id_user_id_fk",
+ "tableFrom": "release_notes",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "release_notes_audience_check": {
+ "name": "release_notes_audience_check",
+ "value": "\"release_notes\".\"audience\" in ('admin', 'editorial', 'both')"
+ },
+ "release_notes_version_check": {
+ "name": "release_notes_version_check",
+ "value": "\"release_notes\".\"version\" ~ '^[0-9]+\\.[0-9]+(\\.[0-9]+)?$'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.download_events": {
+ "name": "download_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "usage_id": {
+ "name": "usage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_asset_id": {
+ "name": "immich_asset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorized_at": {
+ "name": "authorized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "download_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'authorized'"
+ },
+ "transferred_bytes": {
+ "name": "transferred_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repeat_download_note": {
+ "name": "repeat_download_note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent_kind": {
+ "name": "intent_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new_usage'"
+ },
+ "request_fingerprint": {
+ "name": "request_fingerprint",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "legacy_intent": {
+ "name": "legacy_intent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "download_events_editorial_authorized_id_idx": {
+ "name": "download_events_editorial_authorized_id_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "authorized_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "download_events_editorial_idempotency_key_unique": {
+ "name": "download_events_editorial_idempotency_key_unique",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "download_events_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "download_events_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "download_events",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "download_events_usage_id_usages_id_fk": {
+ "name": "download_events_usage_id_usages_id_fk",
+ "tableFrom": "download_events",
+ "tableTo": "usages",
+ "columnsFrom": [
+ "usage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "download_events_intent_kind_check": {
+ "name": "download_events_intent_kind_check",
+ "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download', 'legacy')"
+ },
+ "download_events_request_fingerprint_hex_check": {
+ "name": "download_events_request_fingerprint_hex_check",
+ "value": "\"download_events\".\"request_fingerprint\" ~ '^[0-9a-f]{64}$'"
+ },
+ "download_events_canonical_idempotency_key_check": {
+ "name": "download_events_canonical_idempotency_key_check",
+ "value": "\"download_events\".\"legacy_intent\" OR \"download_events\".\"idempotency_key\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ },
+ "download_events_canonical_immich_asset_id_check": {
+ "name": "download_events_canonical_immich_asset_id_check",
+ "value": "\"download_events\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.usages": {
+ "name": "usages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_asset_id": {
+ "name": "immich_asset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename_snapshot": {
+ "name": "filename_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_album_id_snapshot": {
+ "name": "immich_album_id_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "album_name_snapshot": {
+ "name": "album_name_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purpose": {
+ "name": "purpose",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_reference": {
+ "name": "internal_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_cents": {
+ "name": "price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_status": {
+ "name": "billing_status",
+ "type": "usage_billing_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "billing_report_id": {
+ "name": "billing_report_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "usages_editorial_created_id_idx": {
+ "name": "usages_editorial_created_id_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "usages_created_at_idx": {
+ "name": "usages_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "usages_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "usages_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "usages",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "usages_billing_report_id_billing_reports_id_fk": {
+ "name": "usages_billing_report_id_billing_reports_id_fk",
+ "tableFrom": "usages",
+ "tableTo": "billing_reports",
+ "columnsFrom": [
+ "billing_report_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "usages_canonical_immich_asset_id_check": {
+ "name": "usages_canonical_immich_asset_id_check",
+ "value": "\"usages\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ },
+ "usages_canonical_immich_album_id_check": {
+ "name": "usages_canonical_immich_album_id_check",
+ "value": "\"usages\".\"immich_album_id_snapshot\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ }
+ },
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.portal_role": {
+ "name": "portal_role",
+ "schema": "public",
+ "values": [
+ "ADMIN",
+ "EDITORIAL"
+ ]
+ },
+ "public.report_status": {
+ "name": "report_status",
+ "schema": "public",
+ "values": [
+ "draft",
+ "final",
+ "cancelled"
+ ]
+ },
+ "public.account_status": {
+ "name": "account_status",
+ "schema": "public",
+ "values": [
+ "pending_email",
+ "pending_approval",
+ "active",
+ "suspended",
+ "rejected"
+ ]
+ },
+ "public.download_status": {
+ "name": "download_status",
+ "schema": "public",
+ "values": [
+ "authorized",
+ "streaming",
+ "completed",
+ "failed_before_delivery",
+ "interrupted"
+ ]
+ },
+ "public.usage_billing_status": {
+ "name": "usage_billing_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "billed",
+ "reopened",
+ "voided"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.json
new file mode 100644
index 0000000..371f1ca
--- /dev/null
+++ b/drizzle/meta/0003_snapshot.json
@@ -0,0 +1,2491 @@
+{
+ "id": "2da521e8-f513-403e-84a8-db5502923df2",
+ "prevId": "f708aa98-0633-4a85-9d4b-879142f89a62",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.activity_events": {
+ "name": "activity_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_album_id": {
+ "name": "immich_album_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "immich_asset_id": {
+ "name": "immich_asset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "query": {
+ "name": "query",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "activity_events_occurred_at_idx": {
+ "name": "activity_events_occurred_at_idx",
+ "columns": [
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "activity_events_editorial_occurred_idx": {
+ "name": "activity_events_editorial_occurred_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "activity_events_type_occurred_idx": {
+ "name": "activity_events_type_occurred_idx",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "activity_events_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "activity_events_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "activity_events",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "activity_events_event_type_check": {
+ "name": "activity_events_event_type_check",
+ "value": "\"activity_events\".\"event_type\" in ('album_view', 'search', 'lightbox_view')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.album_grants": {
+ "name": "album_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_album_id": {
+ "name": "immich_album_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_at": {
+ "name": "granted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "granted_by_user_id": {
+ "name": "granted_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'admin'"
+ }
+ },
+ "indexes": {
+ "album_grants_editorial_account_id_idx": {
+ "name": "album_grants_editorial_account_id_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "album_grants_immich_album_id_idx": {
+ "name": "album_grants_immich_album_id_idx",
+ "columns": [
+ {
+ "expression": "immich_album_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "album_grants_editorial_active_album_unique": {
+ "name": "album_grants_editorial_active_album_unique",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"immich_album_id\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"album_grants\".\"revoked_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "album_grants_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "album_grants_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "album_grants",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "album_grants_granted_by_user_id_user_id_fk": {
+ "name": "album_grants_granted_by_user_id_user_id_fk",
+ "tableFrom": "album_grants",
+ "tableTo": "user",
+ "columnsFrom": [
+ "granted_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "album_grants_immich_album_id_uuid_check": {
+ "name": "album_grants_immich_album_id_uuid_check",
+ "value": "\"album_grants\".\"immich_album_id\" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ },
+ "album_grants_source_check": {
+ "name": "album_grants_source_check",
+ "value": "\"album_grants\".\"source\" in ('admin', 'auto_rule', 'self_service')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.announcements": {
+ "name": "announcements",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_date": {
+ "name": "event_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "announcements_created_by_user_id_user_id_fk": {
+ "name": "announcements_created_by_user_id_user_id_fk",
+ "tableFrom": "announcements",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.audit_events": {
+ "name": "audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'system'"
+ },
+ "entity_type": {
+ "name": "entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "previous_values": {
+ "name": "previous_values",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_values": {
+ "name": "new_values",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "audit_events_actor_user_id_user_id_fk": {
+ "name": "audit_events_actor_user_id_user_id_fk",
+ "tableFrom": "audit_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.two_factor": {
+ "name": "two_factor",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "backup_codes": {
+ "name": "backup_codes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verified": {
+ "name": "verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "failed_verification_count": {
+ "name": "failed_verification_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "locked_until": {
+ "name": "locked_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "two_factor_user_id_user_id_fk": {
+ "name": "two_factor_user_id_user_id_fk",
+ "tableFrom": "two_factor",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "two_factor_user_id_unique": {
+ "name": "two_factor_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "portal_role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'EDITORIAL'"
+ },
+ "two_factor_enabled": {
+ "name": "two_factor_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.album_auto_rules": {
+ "name": "album_auto_rules",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "album_auto_rules_editorial_account_id_keyword_idx": {
+ "name": "album_auto_rules_editorial_account_id_keyword_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"keyword\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "album_auto_rules_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "album_auto_rules_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "album_auto_rules",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "album_auto_rules_created_by_user_id_user_id_fk": {
+ "name": "album_auto_rules_created_by_user_id_user_id_fk",
+ "tableFrom": "album_auto_rules",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_report_items": {
+ "name": "billing_report_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "billing_report_id": {
+ "name": "billing_report_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "usage_id": {
+ "name": "usage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_asset_id_snapshot": {
+ "name": "immich_asset_id_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename_snapshot": {
+ "name": "filename_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "album_name_snapshot": {
+ "name": "album_name_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purpose_snapshot": {
+ "name": "purpose_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_reference_snapshot": {
+ "name": "internal_reference_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_cents": {
+ "name": "price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "collab": {
+ "name": "collab",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "billing_report_items_report_usage_unique": {
+ "name": "billing_report_items_report_usage_unique",
+ "columns": [
+ {
+ "expression": "billing_report_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "usage_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "billing_report_items_billing_report_id_billing_reports_id_fk": {
+ "name": "billing_report_items_billing_report_id_billing_reports_id_fk",
+ "tableFrom": "billing_report_items",
+ "tableTo": "billing_reports",
+ "columnsFrom": [
+ "billing_report_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_report_items_usage_id_usages_id_fk": {
+ "name": "billing_report_items_usage_id_usages_id_fk",
+ "tableFrom": "billing_report_items",
+ "tableTo": "usages",
+ "columnsFrom": [
+ "usage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_reports": {
+ "name": "billing_reports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "report_number": {
+ "name": "report_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_starts_at": {
+ "name": "period_starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "period_ends_at": {
+ "name": "period_ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "billing_address_snapshot": {
+ "name": "billing_address_snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "invoice_number": {
+ "name": "invoice_number",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "net_total_cents": {
+ "name": "net_total_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "flatrate_cents_snapshot": {
+ "name": "flatrate_cents_snapshot",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "report_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "pdf": {
+ "name": "pdf",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pdf_sha256": {
+ "name": "pdf_sha256",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invoice_pdf": {
+ "name": "invoice_pdf",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invoice_pdf_sha256": {
+ "name": "invoice_pdf_sha256",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invoice_pdf_filename": {
+ "name": "invoice_pdf_filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invoice_uploaded_at": {
+ "name": "invoice_uploaded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invoice_email_status": {
+ "name": "invoice_email_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'not_sent'"
+ },
+ "invoice_email_sent_at": {
+ "name": "invoice_email_sent_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invoice_email_error": {
+ "name": "invoice_email_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "finalized_at": {
+ "name": "finalized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled_at": {
+ "name": "cancelled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancellation_reason": {
+ "name": "cancellation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cancelled_by_user_id": {
+ "name": "cancelled_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "billing_reports_report_number_unique": {
+ "name": "billing_reports_report_number_unique",
+ "columns": [
+ {
+ "expression": "report_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "billing_reports_invoice_number_unique": {
+ "name": "billing_reports_invoice_number_unique",
+ "columns": [
+ {
+ "expression": "invoice_number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "billing_reports_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "billing_reports",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_reports_created_by_user_id_user_id_fk": {
+ "name": "billing_reports_created_by_user_id_user_id_fk",
+ "tableFrom": "billing_reports",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_reports_cancelled_by_user_id_user_id_fk": {
+ "name": "billing_reports_cancelled_by_user_id_user_id_fk",
+ "tableFrom": "billing_reports",
+ "tableTo": "user",
+ "columnsFrom": [
+ "cancelled_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "billing_reports_pdf_sha256_hex_check": {
+ "name": "billing_reports_pdf_sha256_hex_check",
+ "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'"
+ },
+ "billing_reports_invoice_pdf_sha256_hex_check": {
+ "name": "billing_reports_invoice_pdf_sha256_hex_check",
+ "value": "\"billing_reports\".\"invoice_pdf_sha256\" IS NULL OR \"billing_reports\".\"invoice_pdf_sha256\" ~ '^[0-9a-f]{64}$'"
+ },
+ "billing_reports_invoice_email_status_check": {
+ "name": "billing_reports_invoice_email_status_check",
+ "value": "\"billing_reports\".\"invoice_email_status\" in ('not_sent', 'sent', 'failed')"
+ },
+ "billing_reports_final_pdf_check": {
+ "name": "billing_reports_final_pdf_check",
+ "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.calendar_events": {
+ "name": "calendar_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_date": {
+ "name": "event_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_album_id": {
+ "name": "immich_album_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "calendar_events_created_by_user_id_user_id_fk": {
+ "name": "calendar_events_created_by_user_id_user_id_fk",
+ "tableFrom": "calendar_events",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.event_responses": {
+ "name": "event_responses",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "event_responses_event_editorial_unique": {
+ "name": "event_responses_event_editorial_unique",
+ "columns": [
+ {
+ "expression": "event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "event_responses_event_id_calendar_events_id_fk": {
+ "name": "event_responses_event_id_calendar_events_id_fk",
+ "tableFrom": "event_responses",
+ "tableTo": "calendar_events",
+ "columnsFrom": [
+ "event_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "event_responses_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "event_responses_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "event_responses",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "event_responses_status_check": {
+ "name": "event_responses_status_check",
+ "value": "\"event_responses\".\"status\" in ('attending', 'not_attending')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.billing_address_versions": {
+ "name": "billing_address_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "company_name": {
+ "name": "company_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "contact_name": {
+ "name": "contact_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_1": {
+ "name": "address_line_1",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address_line_2": {
+ "name": "address_line_2",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "postal_code": {
+ "name": "postal_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "city": {
+ "name": "city",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "country_code": {
+ "name": "country_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "valid_from": {
+ "name": "valid_from",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "superseded_by_id": {
+ "name": "superseded_by_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "billing_address_versions",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": {
+ "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk",
+ "tableFrom": "billing_address_versions",
+ "tableTo": "billing_address_versions",
+ "columnsFrom": [
+ "superseded_by_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "billing_address_versions_created_by_user_id_user_id_fk": {
+ "name": "billing_address_versions_created_by_user_id_user_id_fk",
+ "tableFrom": "billing_address_versions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.editorial_accounts": {
+ "name": "editorial_accounts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "contact_name": {
+ "name": "contact_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "login_email": {
+ "name": "login_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "account_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending_email'"
+ },
+ "current_price_cents": {
+ "name": "current_price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flatrate_active": {
+ "name": "flatrate_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "flatrate_price_cents": {
+ "name": "flatrate_price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flatrate_asset_limit": {
+ "name": "flatrate_asset_limit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "collab_enabled": {
+ "name": "collab_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "approval_notice_status": {
+ "name": "approval_notice_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'not_requested'"
+ },
+ "current_billing_address_version_id": {
+ "name": "current_billing_address_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_verified_at": {
+ "name": "email_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_terms_version": {
+ "name": "accepted_terms_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_terms_at": {
+ "name": "accepted_terms_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "privacy_acknowledged_at": {
+ "name": "privacy_acknowledged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_by_user_id": {
+ "name": "archived_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "editorial_accounts_user_id_user_id_fk": {
+ "name": "editorial_accounts_user_id_user_id_fk",
+ "tableFrom": "editorial_accounts",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": {
+ "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk",
+ "tableFrom": "editorial_accounts",
+ "tableTo": "billing_address_versions",
+ "columnsFrom": [
+ "current_billing_address_version_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "editorial_accounts_archived_by_user_id_user_id_fk": {
+ "name": "editorial_accounts_archived_by_user_id_user_id_fk",
+ "tableFrom": "editorial_accounts",
+ "tableTo": "user",
+ "columnsFrom": [
+ "archived_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "editorial_accounts_user_id_unique": {
+ "name": "editorial_accounts_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "editorial_accounts_login_email_unique": {
+ "name": "editorial_accounts_login_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "login_email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.lightbox_items": {
+ "name": "lightbox_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "asset_id": {
+ "name": "asset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "added_at": {
+ "name": "added_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "lightbox_items_editorial_asset_idx": {
+ "name": "lightbox_items_editorial_asset_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "asset_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "lightbox_items_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "lightbox_items_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "lightbox_items",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rate_limits": {
+ "name": "rate_limits",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_boundary": {
+ "name": "window_boundary",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "rate_limits_key_window_boundary_pk": {
+ "name": "rate_limits_key_window_boundary_pk",
+ "columns": [
+ "key",
+ "window_boundary"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.release_notes": {
+ "name": "release_notes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "version": {
+ "name": "version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "audience": {
+ "name": "audience",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'both'"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "release_notes_version_audience_unique": {
+ "name": "release_notes_version_audience_unique",
+ "columns": [
+ {
+ "expression": "version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "audience",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "release_notes_created_by_user_id_user_id_fk": {
+ "name": "release_notes_created_by_user_id_user_id_fk",
+ "tableFrom": "release_notes",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "release_notes_audience_check": {
+ "name": "release_notes_audience_check",
+ "value": "\"release_notes\".\"audience\" in ('admin', 'editorial', 'both')"
+ },
+ "release_notes_version_check": {
+ "name": "release_notes_version_check",
+ "value": "\"release_notes\".\"version\" ~ '^[0-9]+\\.[0-9]+(\\.[0-9]+)?$'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.download_events": {
+ "name": "download_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "usage_id": {
+ "name": "usage_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_asset_id": {
+ "name": "immich_asset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authorized_at": {
+ "name": "authorized_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "download_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'authorized'"
+ },
+ "transferred_bytes": {
+ "name": "transferred_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repeat_download_note": {
+ "name": "repeat_download_note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "idempotency_key": {
+ "name": "idempotency_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "intent_kind": {
+ "name": "intent_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'new_usage'"
+ },
+ "request_fingerprint": {
+ "name": "request_fingerprint",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "legacy_intent": {
+ "name": "legacy_intent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "download_events_editorial_authorized_id_idx": {
+ "name": "download_events_editorial_authorized_id_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "authorized_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "download_events_editorial_idempotency_key_unique": {
+ "name": "download_events_editorial_idempotency_key_unique",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "idempotency_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "download_events_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "download_events_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "download_events",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "download_events_usage_id_usages_id_fk": {
+ "name": "download_events_usage_id_usages_id_fk",
+ "tableFrom": "download_events",
+ "tableTo": "usages",
+ "columnsFrom": [
+ "usage_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "download_events_intent_kind_check": {
+ "name": "download_events_intent_kind_check",
+ "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download', 'legacy')"
+ },
+ "download_events_request_fingerprint_hex_check": {
+ "name": "download_events_request_fingerprint_hex_check",
+ "value": "\"download_events\".\"request_fingerprint\" ~ '^[0-9a-f]{64}$'"
+ },
+ "download_events_canonical_idempotency_key_check": {
+ "name": "download_events_canonical_idempotency_key_check",
+ "value": "\"download_events\".\"legacy_intent\" OR \"download_events\".\"idempotency_key\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ },
+ "download_events_canonical_immich_asset_id_check": {
+ "name": "download_events_canonical_immich_asset_id_check",
+ "value": "\"download_events\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.usages": {
+ "name": "usages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "editorial_account_id": {
+ "name": "editorial_account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_asset_id": {
+ "name": "immich_asset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename_snapshot": {
+ "name": "filename_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "immich_album_id_snapshot": {
+ "name": "immich_album_id_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "album_name_snapshot": {
+ "name": "album_name_snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "purpose": {
+ "name": "purpose",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "internal_reference": {
+ "name": "internal_reference",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "price_cents": {
+ "name": "price_cents",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "collab": {
+ "name": "collab",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "billing_status": {
+ "name": "billing_status",
+ "type": "usage_billing_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "billing_report_id": {
+ "name": "billing_report_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "usages_editorial_created_id_idx": {
+ "name": "usages_editorial_created_id_idx",
+ "columns": [
+ {
+ "expression": "editorial_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "usages_created_at_idx": {
+ "name": "usages_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "usages_editorial_account_id_editorial_accounts_id_fk": {
+ "name": "usages_editorial_account_id_editorial_accounts_id_fk",
+ "tableFrom": "usages",
+ "tableTo": "editorial_accounts",
+ "columnsFrom": [
+ "editorial_account_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "usages_billing_report_id_billing_reports_id_fk": {
+ "name": "usages_billing_report_id_billing_reports_id_fk",
+ "tableFrom": "usages",
+ "tableTo": "billing_reports",
+ "columnsFrom": [
+ "billing_report_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "usages_canonical_immich_asset_id_check": {
+ "name": "usages_canonical_immich_asset_id_check",
+ "value": "\"usages\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ },
+ "usages_canonical_immich_album_id_check": {
+ "name": "usages_canonical_immich_album_id_check",
+ "value": "\"usages\".\"immich_album_id_snapshot\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
+ }
+ },
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.portal_role": {
+ "name": "portal_role",
+ "schema": "public",
+ "values": [
+ "ADMIN",
+ "EDITORIAL"
+ ]
+ },
+ "public.report_status": {
+ "name": "report_status",
+ "schema": "public",
+ "values": [
+ "draft",
+ "final",
+ "cancelled"
+ ]
+ },
+ "public.account_status": {
+ "name": "account_status",
+ "schema": "public",
+ "values": [
+ "pending_email",
+ "pending_approval",
+ "active",
+ "suspended",
+ "rejected"
+ ]
+ },
+ "public.download_status": {
+ "name": "download_status",
+ "schema": "public",
+ "values": [
+ "authorized",
+ "streaming",
+ "completed",
+ "failed_before_delivery",
+ "interrupted"
+ ]
+ },
+ "public.usage_billing_status": {
+ "name": "usage_billing_status",
+ "schema": "public",
+ "values": [
+ "open",
+ "billed",
+ "reopened",
+ "voided"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json
index 081a29d..c8eb1b4 100644
--- a/drizzle/meta/_journal.json
+++ b/drizzle/meta/_journal.json
@@ -15,6 +15,20 @@
"when": 1789139950413,
"tag": "0001_add_announcements",
"breakpoints": true
+ },
+ {
+ "idx": 2,
+ "version": "7",
+ "when": 1796065000672,
+ "tag": "0002_release_notes_calendar",
+ "breakpoints": true
+ },
+ {
+ "idx": 3,
+ "version": "7",
+ "when": 1796067598623,
+ "tag": "0003_collab_invoice_activity",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/public/brand/logo-black-header.png b/public/brand/logo-black-header.png
new file mode 100644
index 0000000..5d9f74c
Binary files /dev/null and b/public/brand/logo-black-header.png differ
diff --git a/public/brand/logo-white-header.png b/public/brand/logo-white-header.png
new file mode 100644
index 0000000..09f1246
Binary files /dev/null and b/public/brand/logo-white-header.png differ
diff --git a/scripts/render-pdf-fixture.ts b/scripts/render-pdf-fixture.ts
index fd69791..588b61b 100644
--- a/scripts/render-pdf-fixture.ts
+++ b/scripts/render-pdf-fixture.ts
@@ -41,6 +41,7 @@ function basePosition(priceCents = 6_000) {
purpose: "Print Nutzung",
reference: "REF-001" as string | null,
priceCents,
+ collab: false,
createdAt: new Date("2026-03-15T10:00:00.000Z"),
};
}
diff --git a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx
index bda4e34..1e8036e 100644
--- a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx
+++ b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx
@@ -17,6 +17,7 @@ const openPosition: BillingPosition = {
purpose: "Titelgeschichte",
reference: "Ausgabe 8/26",
priceCents: 6_000,
+ collab: false,
status: "open",
selectable: true,
createdAt: new Date("2026-08-05T10:00:00.000Z"),
@@ -32,6 +33,7 @@ const billedPosition: BillingPosition = {
purpose: "Sportbericht",
reference: null,
priceCents: 1_500,
+ collab: false,
status: "billed",
selectable: false,
createdAt: new Date("2026-08-06T10:00:00.000Z"),
@@ -47,6 +49,7 @@ const reopenedPosition: BillingPosition = {
purpose: "Reopened",
reference: null,
priceCents: 1_500,
+ collab: false,
status: "reopened",
selectable: true,
createdAt: new Date("2026-08-07T10:00:00.000Z"),
diff --git a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx
index d00e588..d30615f 100644
--- a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx
+++ b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx
@@ -173,6 +173,28 @@ export function BillingSelection({
}
}
+ async function handleToggleCollab(position: BillingPosition) {
+ setActionState({ loading: true, message: null, isError: false });
+ try {
+ const response = await fetch(`/api/usages/${encodeURIComponent(position.id)}/collab`, {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ collab: !position.collab }),
+ });
+ if (!response.ok) {
+ const body = await response.json().catch(() => ({ code: "ERROR" }));
+ throw new Error(body.code ?? "Collab-Kennzeichnung fehlgeschlagen");
+ }
+ window.location.reload();
+ } catch (error) {
+ setActionState({
+ loading: false,
+ message: error instanceof Error ? error.message : "Collab-Kennzeichnung fehlgeschlagen",
+ isError: true,
+ });
+ }
+ }
+
const quarterParam = isQuarter ? null : Math.ceil((month ?? 1) / 3);
const quarterHref = quarter
? `/admin/abrechnungen/${editorialId}?year=${year}&quarter=${quarter}`
@@ -227,7 +249,25 @@ export function BillingSelection({
key: "priceCents",
header: "Preis",
align: "right",
- render: (position) => {formatCents(position.priceCents)},
+ render: (position) => (
+
+
+ {formatCents(position.priceCents)}
+ {position.collab &&
+ Rechnung:{" "} + {report.invoiceEmailStatus === "sent" ? ( + <> + versendet am{" "} + + > + ) : report.hasInvoicePdf ? ( + "PDF hinterlegt, Versand fehlgeschlagen" + ) : ( + "noch keine PDF hinterlegt" + )} +
++ {state.message} +
+ )} ++ Immich ist gerade nicht erreichbar. Verknüpfte Alben werden angezeigt, sobald die Verbindung wieder steht. +
+ ) : null} + +{events.length} insgesamt
++ Noch keine Termine vorhanden. Legen Sie oben den ersten Termin an. +
+ ) : ( ++ {event.title} + {event.eventDate < today ? ( + vorbei + ) : null} +
++ {formatIsoDateGerman(event.eventDate)} ·{" "} + {event.album ? ( + Album: {event.album.albumName} + ) : ( + Noch kein Album verknüpft + )} +
+ {event.responses.length > 0 ? ( +Noch keine Rückmeldungen.
+ )} ++ Zeitraum: {stats.window.fromUtc.toLocaleDateString("de-DE")} bis{" "} + {stats.window.toUtcExclusive.toLocaleDateString("de-DE")} +
+{notes.length} insgesamt
++ Noch keine Versionshinweise vorhanden. +
+ ) : ( ++ Version {note.version} + + {audienceLabels[note.audience]} + +
+{note.body}
++ {new Intl.DateTimeFormat("de-DE", { dateStyle: "medium" }).format(note.createdAt)} +
+@@ -83,6 +94,7 @@ export default async function AlbumPage({ params, searchParams }: AlbumPageProps query={query} format={format} jahr={jahr} + sortierung={sortierung} />
{formatCount(page.total, "Foto")} gefunden
@@ -63,7 +67,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi lightboxAssetIds={page.items.filter(({ id }) => lightboxAssetIds.has(id)).map(({ id }) => id)} showAlbumName /> -+ {error} +
+ ) : null} ++ {error} +
+ ) : null} ++ Das Bildarchiv ist gerade nicht erreichbar. Termine und Rückmeldungen funktionieren weiterhin, Alben erscheinen wieder, sobald die Verbindung steht. +
+ ) : null} + + {ordered.length === 0 ? ( ++ Zurzeit sind keine Termine eingetragen. Sobald ein Spiel oder Event geplant ist, erscheint es hier. +
+ ) : ( ++ {event.title} + {event.eventDate < today ? ( + vorbei + ) : null} +
+{formatIsoDateGerman(event.eventDate)}
+ {event.album ? null : ( +Album noch nicht angelegt.
+ )} +- {newPhotos.length} neue {newPhotos.length === 1 ? "Nutzung" : "Nutzungen"} · bis{" "} - {priceFormatter.format(newPhotos.length * options.priceCents / 100)} netto. - Ein verfügbares Flatrate-Kontingent wird beim Download angerechnet. + {newPhotos.length} neue {newPhotos.length === 1 ? "Nutzung" : "Nutzungen"} ·{" "} + {collab + ? "kostenfrei als Collab-Nutzung." + : `bis ${priceFormatter.format(newPhotos.length * options.priceCents / 100)} netto. Ein verfügbares Flatrate-Kontingent wird beim Download angerechnet.`}
)} {selected.length > 100 &&+ Noch keine Versionshinweise vorhanden. +
+ ) : ( ++ Version {note.version} + + {new Intl.DateTimeFormat("de-DE", { dateStyle: "medium" }).format(note.createdAt)} + +
+{note.body}
+