35 lines
3.8 KiB
SQL
35 lines
3.8 KiB
SQL
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; |