CREATE TABLE `audit_events` ( `id` text PRIMARY KEY NOT NULL, `space_id` text NOT NULL, `actor_id` text, `action` text NOT NULL, `target_type` text, `target_id` text, `metadata` text, `created_at` integer NOT NULL, FOREIGN KEY (`space_id`) REFERENCES `spaces`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`actor_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null ); --> statement-breakpoint CREATE INDEX `idx_audit_events_space_created` ON `audit_events` (`space_id`,`created_at`);--> statement-breakpoint CREATE INDEX `idx_audit_events_actor` ON `audit_events` (`actor_id`);