CREATE TABLE `job_files` ( `job_id` text NOT NULL, `model_file_id` text NOT NULL, `path` text NOT NULL, `expected_bytes` integer NOT NULL, `done_bytes` integer DEFAULT 0 NOT NULL, `state` text DEFAULT 'pending' NOT NULL, PRIMARY KEY(`job_id`, `model_file_id`), FOREIGN KEY (`job_id`) REFERENCES `jobs`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`model_file_id`) REFERENCES `model_files`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `job_logs` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `job_id` text NOT NULL, `ts` integer NOT NULL, `stream` text NOT NULL, `line` text NOT NULL, FOREIGN KEY (`job_id`) REFERENCES `jobs`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE INDEX `job_logs_job_idx` ON `job_logs` (`job_id`,`id`);--> statement-breakpoint CREATE TABLE `jobs` ( `id` text PRIMARY KEY NOT NULL, `model_id` text NOT NULL, `kind` text NOT NULL, `purpose` text, `target_sha` text NOT NULL, `state` text DEFAULT 'queued' NOT NULL, `attempt` integer DEFAULT 0 NOT NULL, `total_bytes` integer DEFAULT 0 NOT NULL, `done_bytes` integer DEFAULT 0 NOT NULL, `speed_bps` integer, `eta_seconds` integer, `exit_code` integer, `error_code` text, `error_message` text, `cancel_requested_at` integer, `started_at` integer, `finished_at` integer, `created_at` integer NOT NULL, `updated_at` integer NOT NULL, FOREIGN KEY (`model_id`) REFERENCES `models`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE INDEX `jobs_state_idx` ON `jobs` (`state`);--> statement-breakpoint CREATE INDEX `jobs_model_idx` ON `jobs` (`model_id`);--> statement-breakpoint CREATE TABLE `model_files` ( `id` text PRIMARY KEY NOT NULL, `model_id` text NOT NULL, `path` text NOT NULL, `size` integer NOT NULL, `blob_oid` text, `lfs_sha256` text, `selected` integer DEFAULT false NOT NULL, `state` text DEFAULT 'pending' NOT NULL, `checked_at` integer, `created_at` integer NOT NULL, `updated_at` integer NOT NULL, FOREIGN KEY (`model_id`) REFERENCES `models`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE UNIQUE INDEX `model_files_model_path_uq` ON `model_files` (`model_id`,`path`);--> statement-breakpoint CREATE TABLE `model_revisions` ( `id` text PRIMARY KEY NOT NULL, `model_id` text NOT NULL, `sha` text NOT NULL, `pinned_at` integer NOT NULL, `superseded_at` integer, FOREIGN KEY (`model_id`) REFERENCES `models`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE INDEX `model_revisions_model_idx` ON `model_revisions` (`model_id`);--> statement-breakpoint CREATE TABLE `models` ( `id` text PRIMARY KEY NOT NULL, `repo_type` text DEFAULT 'model' NOT NULL, `repo_id` text NOT NULL, `tracked_revision` text DEFAULT 'main' NOT NULL, `pinned_sha` text NOT NULL, `local_path` text NOT NULL, `include_patterns` text DEFAULT '[]' NOT NULL, `exclude_patterns` text DEFAULT '[]' NOT NULL, `status` text DEFAULT 'pending' NOT NULL, `remote_sha` text, `last_checked_at` integer, `last_check_error` text, `last_verified_at` integer, `downloaded_at` integer, `created_at` integer NOT NULL, `updated_at` integer NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `models_repo_uq` ON `models` (`repo_type`,`repo_id`);--> statement-breakpoint CREATE TABLE `worker_state` ( `id` text PRIMARY KEY NOT NULL, `pid` integer, `hf_version` text, `started_at` integer NOT NULL, `heartbeat_at` integer NOT NULL );