CREATE TABLE `docker_compose_roots` (
	`id` text PRIMARY KEY NOT NULL,
	`machine_id` text NOT NULL,
	`path` text NOT NULL,
	`enabled` integer DEFAULT 1 NOT NULL,
	`scan_depth` integer,
	`created_at` text NOT NULL,
	`updated_at` text NOT NULL,
	FOREIGN KEY (`machine_id`) REFERENCES `machines`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `docker_compose_stacks` (
	`id` text PRIMARY KEY NOT NULL,
	`machine_id` text NOT NULL,
	`name` text NOT NULL,
	`working_dir` text NOT NULL,
	`compose_files_json` text NOT NULL,
	`project_name` text,
	`env_file` text,
	`status` text NOT NULL,
	`detected_by` text,
	`last_scan_at` text,
	`last_update_at` text,
	`created_at` text NOT NULL,
	`updated_at` text NOT NULL,
	FOREIGN KEY (`machine_id`) REFERENCES `machines`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `docker_settings` (
	`machine_id` text PRIMARY KEY NOT NULL,
	`enabled` integer DEFAULT 0 NOT NULL,
	`scan_depth` integer DEFAULT 4 NOT NULL,
	`prune_mode` text DEFAULT 'safe' NOT NULL,
	`last_scan_at` text,
	`last_pull_check_at` text,
	`updated_at` text NOT NULL,
	FOREIGN KEY (`machine_id`) REFERENCES `machines`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `docker_stack_services` (
	`id` text PRIMARY KEY NOT NULL,
	`stack_id` text NOT NULL,
	`service_name` text NOT NULL,
	`image_ref` text,
	`current_image_id` text,
	`current_digest` text,
	`candidate_image_id` text,
	`candidate_digest` text,
	`version_label` text,
	`status` text,
	`updated_at` text NOT NULL,
	FOREIGN KEY (`stack_id`) REFERENCES `docker_compose_stacks`(`id`) ON UPDATE no action ON DELETE cascade
);
