CREATE TABLE `admin_sessions` ( `id` text PRIMARY KEY NOT NULL, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `expires_at` text NOT NULL ); --> statement-breakpoint CREATE TABLE `api_keys` ( `id` text PRIMARY KEY NOT NULL, `name` text NOT NULL, `key_hash` text NOT NULL, `key_prefix` text NOT NULL, `enabled` integer DEFAULT true NOT NULL, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `last_used_at` text ); --> statement-breakpoint CREATE UNIQUE INDEX `api_keys_key_hash_unique` ON `api_keys` (`key_hash`);--> statement-breakpoint CREATE TABLE `audit_logs` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `ts` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `actor` text NOT NULL, `session_id` text, `kind` text NOT NULL, `summary` text NOT NULL, `detail` text ); --> statement-breakpoint CREATE INDEX `audit_ts_idx` ON `audit_logs` (`ts`);--> statement-breakpoint CREATE TABLE `events` ( `session_id` text NOT NULL, `seq` integer NOT NULL, `run_id` text, `type` text NOT NULL, `payload` text NOT NULL, `ts` text NOT NULL, PRIMARY KEY(`session_id`, `seq`) ); --> statement-breakpoint CREATE TABLE `files` ( `id` text PRIMARY KEY NOT NULL, `session_id` text NOT NULL, `rel_path` text NOT NULL, `origin` text NOT NULL, `mime` text NOT NULL, `size` integer NOT NULL, `mtime_ms` real NOT NULL, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL ); --> statement-breakpoint CREATE INDEX `files_session_path_idx` ON `files` (`session_id`,`rel_path`);--> statement-breakpoint CREATE TABLE `interactions` ( `id` text PRIMARY KEY NOT NULL, `session_id` text NOT NULL, `run_id` text NOT NULL, `kind` text NOT NULL, `request` text NOT NULL, `response` text, `status` text NOT NULL, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `resolved_at` text, `expires_at` text NOT NULL ); --> statement-breakpoint CREATE INDEX `interactions_session_idx` ON `interactions` (`session_id`,`status`);--> statement-breakpoint CREATE TABLE `knowledge_roots` ( `id` text PRIMARY KEY NOT NULL, `name` text NOT NULL, `path` text NOT NULL, `description` text DEFAULT '' NOT NULL, `access` text DEFAULT 'read' NOT NULL, `enabled` integer DEFAULT true NOT NULL, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL ); --> statement-breakpoint CREATE TABLE `profiles` ( `id` text PRIMARY KEY NOT NULL, `name` text NOT NULL, `description` text DEFAULT '' NOT NULL, `provider` text NOT NULL, `model` text NOT NULL, `system_prompt` text DEFAULT '' NOT NULL, `permission_mode` text DEFAULT 'ask' NOT NULL, `allowed_tools` text DEFAULT '[]' NOT NULL, `disallowed_tools` text DEFAULT '[]' NOT NULL, `skills` text DEFAULT '"all"' NOT NULL, `file_access` text NOT NULL, `knowledge_root_ids` text DEFAULT '[]' NOT NULL, `is_default` integer DEFAULT false NOT NULL, `version` integer DEFAULT 1 NOT NULL, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL ); --> statement-breakpoint CREATE TABLE `runs` ( `id` text PRIMARY KEY NOT NULL, `session_id` text NOT NULL, `status` text NOT NULL, `started_at` text, `ended_at` text, `input_tokens` integer, `output_tokens` integer, `cache_read_tokens` integer, `cache_write_tokens` integer, `cost_usd` real, `error` text, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL ); --> statement-breakpoint CREATE INDEX `runs_session_idx` ON `runs` (`session_id`);--> statement-breakpoint CREATE TABLE `sessions` ( `id` text PRIMARY KEY NOT NULL, `source` text NOT NULL, `profile_id` text, `provider` text NOT NULL, `model` text NOT NULL, `permission_mode` text NOT NULL, `system_prompt_append` text DEFAULT '' NOT NULL, `provider_session_id` text, `workspace_dir` text NOT NULL, `title` text DEFAULT '' NOT NULL, `last_seq` integer DEFAULT 0 NOT NULL, `archived` integer DEFAULT false NOT NULL, `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL, `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL ); --> statement-breakpoint CREATE INDEX `sessions_source_idx` ON `sessions` (`source`,`updated_at`);--> statement-breakpoint CREATE TABLE `settings` ( `key` text PRIMARY KEY NOT NULL, `value` text NOT NULL, `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL );