CREATE TABLE `action_requests` (
	`id` text PRIMARY KEY NOT NULL,
	`machine_id` text,
	`requested_by_type` text NOT NULL,
	`requested_by_id` text,
	`action` text NOT NULL,
	`risk` text,
	`status` text NOT NULL,
	`summary` text,
	`payload_json` text,
	`created_at` text NOT NULL,
	`approved_at` text,
	`approved_by` text,
	`execution_id` text,
	`expires_at` text,
	FOREIGN KEY (`machine_id`) REFERENCES `machines`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `docker_image_events` (
	`id` text PRIMARY KEY NOT NULL,
	`execution_id` text,
	`machine_id` text NOT NULL,
	`stack_id` text,
	`service_name` text,
	`image_ref` text,
	`from_image_id` text,
	`to_image_id` text,
	`from_digest` text,
	`to_digest` text,
	`operation` text,
	`bytes_reclaimed` integer,
	`created_at` text NOT NULL,
	FOREIGN KEY (`execution_id`) REFERENCES `executions`(`id`) ON UPDATE no action ON DELETE set null
);
