This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/database/migrations/sqlite/008_tasks.sql
Jeffrey Smith ebea16344c step 4: fresh kernel-only migrations
Deleted all 23+23 old chat-switchboard migration files.
Wrote 9+9 clean kernel-only migrations in postgres/ and sqlite/ subdirs.

27 tables per dialect covering all 20 store interfaces:
  001: users, refresh_tokens, policies, settings, presence, oidc
  002: teams, team_members, groups, group_members
  003: packages, package_user_settings, ext_permissions, ext_data_tables
  004: ext_connections, ext_dependencies, resource_grants
  005: notifications, notification_preferences
  006: audit_log
  007: workflows, workflow_stages, workflow_versions
  008: tasks, task_runs
  009: ws_tickets, rate_limit_counters

Dropped: providers, personas, channels, messages, knowledge, notes,
memory, workspaces, projects, folders, files, usage_log, tool_health,
workflow_assignments, ext_view_channels.

Schema changes vs old:
  - pgvector extension removed (no KB embeddings)
  - resource_grants: resource_type CHECK removed (open-ended)
  - workflow_stages: persona_id kept as nullable TEXT (no FK)
  - workflow_stages: stage_mode default=form_only, added custom
  - tasks: dropped output_channel_id, provider_config_id columns
  - tasks: task_type removed prompt, output_mode: notification|webhook|log
  - task_runs: dropped channel_id
  - platform_policies: kernel-only seeds
  - global_settings: kernel-only seeds, site name=Switchboard Core
  - Everyone group: kernel permissions (extension.use, workflow.submit)

-2815/+487 lines.
2026-03-25 20:22:02 -04:00

63 lines
2.8 KiB
SQL

-- ==========================================
-- Switchboard Core — 008 Tasks (SQLite)
-- ==========================================
CREATE TABLE IF NOT EXISTS tasks (
id TEXT PRIMARY KEY,
owner_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
team_id TEXT REFERENCES teams(id) ON DELETE SET NULL,
name TEXT NOT NULL,
description TEXT DEFAULT '',
scope TEXT NOT NULL DEFAULT 'personal'
CHECK (scope IN ('personal', 'team', 'global')),
task_type TEXT NOT NULL DEFAULT 'action'
CHECK (task_type IN ('action', 'workflow', 'system')),
system_function TEXT DEFAULT '',
persona_id TEXT,
model_id TEXT,
system_prompt TEXT DEFAULT '',
user_prompt TEXT DEFAULT '',
workflow_id TEXT REFERENCES workflows(id) ON DELETE SET NULL,
tool_grants TEXT,
schedule TEXT NOT NULL,
timezone TEXT NOT NULL DEFAULT 'UTC',
is_active INTEGER NOT NULL DEFAULT 1,
trigger_token TEXT UNIQUE,
max_tokens INTEGER NOT NULL DEFAULT 4096,
max_tool_calls INTEGER NOT NULL DEFAULT 10,
max_wall_clock INTEGER NOT NULL DEFAULT 300,
output_mode TEXT NOT NULL DEFAULT 'log'
CHECK (output_mode IN ('notification', 'webhook', 'log')),
webhook_url TEXT,
webhook_secret TEXT,
notify_on_complete INTEGER NOT NULL DEFAULT 0,
notify_on_failure INTEGER NOT NULL DEFAULT 1,
last_run_at TEXT,
next_run_at TEXT,
run_count INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE INDEX IF NOT EXISTS idx_tasks_next_run ON tasks(next_run_at);
CREATE INDEX IF NOT EXISTS idx_tasks_owner ON tasks(owner_id);
CREATE INDEX IF NOT EXISTS idx_tasks_team ON tasks(team_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_trigger_token ON tasks(trigger_token);
CREATE TABLE IF NOT EXISTS task_runs (
id TEXT PRIMARY KEY,
task_id TEXT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
status TEXT NOT NULL DEFAULT 'running'
CHECK (status IN ('queued', 'running', 'completed', 'failed', 'budget_exceeded', 'cancelled')),
trigger_payload TEXT,
started_at TEXT NOT NULL DEFAULT (datetime('now')),
completed_at TEXT,
tokens_used INTEGER DEFAULT 0,
tool_calls INTEGER DEFAULT 0,
wall_clock INTEGER DEFAULT 0,
error TEXT
);
CREATE INDEX IF NOT EXISTS idx_task_runs_task ON task_runs(task_id);
CREATE INDEX IF NOT EXISTS idx_task_runs_status ON task_runs(task_id, status);