Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

feat(db): let the audit log record MCP, publishing, media and YouTube changes

spacesdrive7fdf54ff6794
diff --git a/backend/repositories/auditRepository.ts b/backend/repositories/auditRepository.ts
index 3b15462..58981b3 100644
--- a/backend/repositories/auditRepository.ts
+++ b/backend/repositories/auditRepository.ts
@@ -2,7 +2,10 @@ import { execute, rows } from './query.ts';
import { newRowId } from '../lib/ids.ts';
import type { SupabaseClient } from '../types/app.ts';
-export type AuditSubjectType = 'account' | 'automation_rule' | 'automation_account' | 'automation_comment';
+export type AuditSubjectType =
+ | 'account' | 'automation_rule' | 'automation_account' | 'automation_comment'
+ | 'mcp_access_token' | 'mcp_client' | 'scheduled_post' | 'tracked_post' | 'media_asset'
+ | 'youtube_connection' | 'youtube_upload' | 'settings';
// action is "<subject>.<verb>", such as account.removed or automation_rule.updated
export interface AuditEvent {
diff --git a/supabase/migrations/20261104213157_alter_audit_events_subject_types.sql b/supabase/migrations/20261104213157_alter_audit_events_subject_types.sql
new file mode 100644
index 0000000..9e8a3a8
--- /dev/null
+++ b/supabase/migrations/20261104213157_alter_audit_events_subject_types.sql
@@ -0,0 +1,8 @@
+-- lets audit_events record changes made through Claude clients, publishing, media and YouTube
+alter table public.audit_events
+ drop constraint audit_events_subject_type_check,
+ add constraint audit_events_subject_type_check check (subject_type in (
+ 'account', 'automation_rule', 'automation_account', 'automation_comment',
+ 'mcp_access_token', 'mcp_client', 'scheduled_post', 'tracked_post', 'media_asset',
+ 'youtube_connection', 'youtube_upload', 'settings'
+ ));
diff --git a/supabase/rollbacks/20261104213157_alter_audit_events_subject_types.sql b/supabase/rollbacks/20261104213157_alter_audit_events_subject_types.sql
new file mode 100644
index 0000000..d6e1e8f
--- /dev/null
+++ b/supabase/rollbacks/20261104213157_alter_audit_events_subject_types.sql
@@ -0,0 +1,6 @@
+-- limits audit_events to the original four subject types; delete rows with the newer types first
+alter table public.audit_events
+ drop constraint audit_events_subject_type_check,
+ add constraint audit_events_subject_type_check check (subject_type in (
+ 'account', 'automation_rule', 'automation_account', 'automation_comment'
+ ));
diff --git a/supabase/schemas/public/tables/audit_events.sql b/supabase/schemas/public/tables/audit_events.sql
index 0a8ede1..4644b54 100644
--- a/supabase/schemas/public/tables/audit_events.sql
+++ b/supabase/schemas/public/tables/audit_events.sql
@@ -11,7 +11,8 @@ CREATE TABLE "public"."audit_events" (
CONSTRAINT "audit_events_details_check" CHECK ((jsonb_typeof(details) = 'object'::text)),
CONSTRAINT "audit_events_pkey" PRIMARY KEY (id),
CONSTRAINT "audit_events_subject_type_check"
- CHECK ((subject_type = ANY (ARRAY['account'::text, 'automation_rule'::text, 'automation_account'::text, 'automation_comment'::text]))),
+ CHECK ((subject_type = ANY (ARRAY['account'::text, 'automation_rule'::text, 'automation_account'::text, 'automation_comment'::text, 'mcp_access_token'::text, 'mcp_client'::text, 'scheduled_post'::text,
+ 'tracked_post'::text, 'media_asset'::text, 'youtube_connection'::text, 'youtube_upload'::text, 'settings'::text]))),
CONSTRAINT "audit_events_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE
);