CREATE TABLE `scheduled_tasks` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`server_id` integer NOT NULL,
	`schedule_type` text NOT NULL,
	`name` text NOT NULL,
	`command` text,
	`schedule_expression` text,
	`source` text,
	`enabled` integer DEFAULT true NOT NULL,
	`next_run_at` text,
	`raw_metadata` text,
	`is_stale` integer DEFAULT false NOT NULL,
	`first_seen_at` text DEFAULT (current_timestamp) NOT NULL,
	`last_seen_at` text DEFAULT (current_timestamp) NOT NULL,
	FOREIGN KEY (`server_id`) REFERENCES `servers`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `servers` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`name` text NOT NULL,
	`hostname` text,
	`os_type` text DEFAULT 'linux' NOT NULL,
	`description` text,
	`api_token_hash` text NOT NULL,
	`api_token_prefix` text NOT NULL,
	`created_at` text DEFAULT (current_timestamp) NOT NULL,
	`last_seen_at` text
);
