feat: add workflow orchestration and media governance
This commit is contained in:
@@ -990,6 +990,46 @@ CREATE TABLE IF NOT EXISTS system_settings (
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- Workflow templates are versioned production contracts. Global templates can
|
||||
-- be overridden at organization or workspace scope without changing project
|
||||
-- content already in production.
|
||||
CREATE TABLE IF NOT EXISTS workflow_templates (
|
||||
id TEXT PRIMARY KEY,
|
||||
organization_id TEXT REFERENCES organizations(id) ON DELETE CASCADE,
|
||||
workspace_id TEXT REFERENCES workspaces(id) ON DELETE CASCADE,
|
||||
template_key TEXT NOT NULL,
|
||||
version_number INTEGER NOT NULL DEFAULT 1,
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL DEFAULT 'ai-manhua-drama',
|
||||
status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'active', 'archived')),
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
steps_json TEXT NOT NULL DEFAULT '[]',
|
||||
gates_json TEXT NOT NULL DEFAULT '[]',
|
||||
default_adapter_id TEXT NOT NULL DEFAULT '',
|
||||
created_by TEXT REFERENCES users(id),
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
UNIQUE (organization_id, workspace_id, template_key, version_number)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS workflow_runs (
|
||||
id TEXT PRIMARY KEY,
|
||||
organization_id TEXT NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
||||
workspace_id TEXT NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
|
||||
project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
||||
episode_id TEXT REFERENCES episodes(id) ON DELETE SET NULL,
|
||||
shot_id TEXT REFERENCES shots(id) ON DELETE SET NULL,
|
||||
template_id TEXT NOT NULL REFERENCES workflow_templates(id),
|
||||
status TEXT NOT NULL DEFAULT 'planned' CHECK (status IN ('planned', 'queued', 'running', 'blocked', 'completed', 'failed', 'cancelled')),
|
||||
current_step_index INTEGER NOT NULL DEFAULT 0,
|
||||
steps_json TEXT NOT NULL DEFAULT '[]',
|
||||
job_ids_json TEXT NOT NULL DEFAULT '[]',
|
||||
error_message TEXT NOT NULL DEFAULT '',
|
||||
created_by TEXT NOT NULL REFERENCES users(id),
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS feature_flags (
|
||||
key TEXT PRIMARY KEY,
|
||||
label TEXT NOT NULL,
|
||||
@@ -1161,6 +1201,8 @@ CREATE INDEX IF NOT EXISTS idx_audit_scope ON audit_logs(organization_id, worksp
|
||||
CREATE INDEX IF NOT EXISTS idx_invites_scope ON invitations(organization_id, status, created_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_job_dependencies_dependency ON job_dependencies(depends_on_job_id, job_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_system_settings_category ON system_settings(category, updated_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_workflow_templates_scope ON workflow_templates(organization_id, workspace_id, status, template_key, version_number DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_workflow_runs_scope ON workflow_runs(organization_id, workspace_id, project_id, status, created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_feature_flags_scope ON feature_flags(scope, enabled);
|
||||
CREATE INDEX IF NOT EXISTS idx_notification_channels_enabled ON notification_channels(enabled, kind);
|
||||
CREATE INDEX IF NOT EXISTS idx_notification_deliveries_scope ON notification_deliveries(organization_id, created_at);
|
||||
|
||||
Reference in New Issue
Block a user