Files
Bookra/apps/backend/migrations/00016_activity_events.sql
T
Tomas DvorakandDevin d86cba61e3 feat(activity): per-tenant audit feed in notification dropdown
activity_events records booking lifecycle transitions with the actor
behind each change — staff (dashboard), customer (self-service), or
system (auto-promotion). The notification dropdown leads with the real
feed instead of derived recent-booking guesses.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 16:06:13 +02:00

22 lines
876 B
SQL

-- +goose Up
-- Per-tenant activity feed: who changed what. Actor kinds distinguish
-- dashboard users (staff), public self-service actions (customer), and
-- automatic transitions (system). Kept to booking lifecycle events in v1.
CREATE TABLE activity_events (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
actor_kind text NOT NULL DEFAULT 'staff',
actor_subject text NOT NULL DEFAULT '',
actor_name text NOT NULL DEFAULT '',
action text NOT NULL,
entity_type text NOT NULL DEFAULT 'booking',
entity_id uuid,
summary text NOT NULL DEFAULT '',
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX activity_events_tenant_created_idx
ON activity_events (tenant_id, created_at DESC);
-- +goose Down
DROP TABLE IF EXISTS activity_events;