// Generated by scripts/gen-scoped-schema.ts from the D1 migrations up to 0057_drop_moved_tables.sql. Do not edit; rerun // the script. New scoped-table DDL goes in schema-extra.ts. /* oxlint-disable max-lines */ export const REPO_SCHEMA: readonly string[] = [ "CREATE TABLE IF NOT EXISTS issues (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n number INTEGER NOT NULL,\n author_id TEXT NOT NULL,\n title TEXT NOT NULL,\n body TEXT NOT NULL DEFAULT '',\n state TEXT NOT NULL CHECK (state IN ('open', 'closed')),\n is_pull INTEGER NOT NULL DEFAULT 0,\n comments_count INTEGER NOT NULL DEFAULT 0,\n locked INTEGER NOT NULL DEFAULT 0,\n closed_at INTEGER,\n closed_by TEXT,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n milestone_id TEXT REFERENCES milestones(id) ON DELETE SET NULL,\n type_id TEXT REFERENCES issue_types(id) ON DELETE SET NULL,\n parent_id TEXT REFERENCES issues(id) ON DELETE SET NULL, hidden_at INTEGER,\n UNIQUE (repo_id, number)\n)", "CREATE INDEX IF NOT EXISTS issues_repo_state ON issues(repo_id, is_pull, state, number DESC)", "CREATE INDEX IF NOT EXISTS issues_author ON issues(author_id)", "CREATE INDEX IF NOT EXISTS issues_milestone ON issues(milestone_id, state)", "CREATE INDEX IF NOT EXISTS issues_parent ON issues(parent_id, state)", "CREATE TABLE IF NOT EXISTS pull_requests (\n issue_id TEXT PRIMARY KEY REFERENCES issues(id) ON DELETE CASCADE,\n repo_id TEXT NOT NULL,\n head_repo_id TEXT NOT NULL,\n head_ref TEXT NOT NULL,\n head_sha TEXT NOT NULL,\n base_ref TEXT NOT NULL,\n base_sha TEXT NOT NULL,\n merge_base_sha TEXT,\n draft INTEGER NOT NULL DEFAULT 0,\n mergeable TEXT NOT NULL DEFAULT 'unknown' CHECK (mergeable IN ('unknown', 'clean', 'conflict')),\n merged_at INTEGER,\n merged_by TEXT,\n merge_commit_sha TEXT,\n merge_method TEXT,\n refs_swept_at INTEGER\n, bridged_bytes INTEGER NOT NULL DEFAULT 0, stacked_on_issue_id TEXT REFERENCES issues(id) ON DELETE SET NULL, restack_upstream_sha TEXT)", "CREATE INDEX IF NOT EXISTS pull_requests_head ON pull_requests(head_repo_id, head_ref)", "CREATE INDEX IF NOT EXISTS pull_requests_base ON pull_requests(repo_id, base_ref)", "CREATE TABLE IF NOT EXISTS comments (\n id TEXT PRIMARY KEY,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n author_id TEXT NOT NULL,\n body TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n, hidden_at INTEGER)", "CREATE INDEX IF NOT EXISTS comments_issue ON comments(issue_id, created_at)", "CREATE TABLE IF NOT EXISTS issue_events (\n id TEXT PRIMARY KEY,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n actor_id TEXT,\n kind TEXT NOT NULL,\n data TEXT NOT NULL DEFAULT '{}',\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS issue_events_issue ON issue_events(issue_id, created_at)", "CREATE TABLE IF NOT EXISTS reviews (\n id TEXT PRIMARY KEY,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n author_id TEXT NOT NULL,\n state TEXT NOT NULL CHECK (state IN ('approved', 'changes_requested', 'commented', 'dismissed')),\n body TEXT NOT NULL DEFAULT '',\n commit_sha TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n dismissed_by TEXT,\n dismiss_reason TEXT\n)", "CREATE INDEX IF NOT EXISTS reviews_issue ON reviews(issue_id, created_at)", "CREATE TABLE IF NOT EXISTS review_comments (\n id TEXT PRIMARY KEY,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n review_id TEXT REFERENCES reviews(id) ON DELETE CASCADE,\n author_id TEXT NOT NULL,\n path TEXT NOT NULL,\n line INTEGER NOT NULL,\n side TEXT NOT NULL CHECK (side IN ('LEFT', 'RIGHT')),\n commit_sha TEXT NOT NULL,\n body TEXT NOT NULL,\n in_reply_to TEXT REFERENCES review_comments(id) ON DELETE CASCADE,\n resolved INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n start_line INTEGER,\n start_side TEXT CHECK (start_side IN ('LEFT', 'RIGHT')),\n suggestion_applied_sha TEXT\n, hidden_at INTEGER)", "CREATE INDEX IF NOT EXISTS review_comments_issue ON review_comments(issue_id, path, line)", "CREATE TABLE IF NOT EXISTS review_requests (\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n user_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n code_owner INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (issue_id, user_id)\n)", "CREATE TABLE IF NOT EXISTS labels (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n name TEXT NOT NULL COLLATE NOCASE,\n color TEXT NOT NULL,\n description TEXT,\n UNIQUE (repo_id, name)\n)", "CREATE TABLE IF NOT EXISTS issue_labels (\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n label_id TEXT NOT NULL REFERENCES labels(id) ON DELETE CASCADE,\n PRIMARY KEY (issue_id, label_id)\n)", "CREATE INDEX IF NOT EXISTS issue_labels_label ON issue_labels(label_id)", "CREATE TABLE IF NOT EXISTS issue_assignees (\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n user_id TEXT NOT NULL,\n PRIMARY KEY (issue_id, user_id)\n)", "CREATE INDEX IF NOT EXISTS issue_assignees_user ON issue_assignees(user_id)", "CREATE TABLE IF NOT EXISTS branch_protections (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n pattern TEXT NOT NULL,\n require_pull_request INTEGER NOT NULL DEFAULT 1,\n required_approvals INTEGER NOT NULL DEFAULT 0,\n required_checks TEXT NOT NULL DEFAULT '[]',\n dismiss_stale_reviews INTEGER NOT NULL DEFAULT 0,\n allow_deletions INTEGER NOT NULL DEFAULT 0,\n enforce_admins INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n require_code_owner_review INTEGER NOT NULL DEFAULT 0,\n allow_force_pushes INTEGER NOT NULL DEFAULT 0,\n UNIQUE (repo_id, pattern)\n)", "CREATE TABLE IF NOT EXISTS webhooks (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n url TEXT NOT NULL,\n secret TEXT,\n events TEXT NOT NULL,\n active INTEGER NOT NULL DEFAULT 1,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS webhooks_repo ON webhooks(repo_id)", "CREATE TABLE IF NOT EXISTS webhook_deliveries (\n id TEXT PRIMARY KEY,\n webhook_id TEXT NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE,\n event TEXT NOT NULL,\n status_code INTEGER,\n error TEXT,\n request_body TEXT NOT NULL,\n response_body TEXT,\n duration_ms INTEGER,\n attempt INTEGER NOT NULL,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS webhook_deliveries_hook ON webhook_deliveries(webhook_id, created_at DESC)", "CREATE TABLE IF NOT EXISTS secrets (\n repo_id TEXT NOT NULL,\n name TEXT NOT NULL,\n ciphertext TEXT NOT NULL,\n iv TEXT NOT NULL,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, name)\n)", "CREATE TABLE IF NOT EXISTS workflow_runs (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n source_repo_id TEXT NOT NULL,\n run_number INTEGER NOT NULL,\n workflow_path TEXT NOT NULL,\n workflow_name TEXT NOT NULL,\n event TEXT NOT NULL,\n ref TEXT NOT NULL,\n sha TEXT NOT NULL,\n title TEXT NOT NULL,\n actor_id TEXT,\n pr_number INTEGER,\n status TEXT NOT NULL CHECK (status IN ('queued', 'in_progress', 'completed')),\n conclusion TEXT CHECK (conclusion IN ('success', 'failure', 'cancelled', 'skipped')),\n created_at INTEGER NOT NULL,\n started_at INTEGER,\n completed_at INTEGER,\n approval_required INTEGER NOT NULL DEFAULT 0,\n workflow_source TEXT,\n context TEXT,\n trigger_depth INTEGER NOT NULL DEFAULT 0,\n rerun_of TEXT,\n untrusted INTEGER NOT NULL DEFAULT 0,\n UNIQUE (repo_id, run_number)\n)", "CREATE INDEX IF NOT EXISTS workflow_runs_repo ON workflow_runs(repo_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS workflow_runs_sha ON workflow_runs(repo_id, sha)", "CREATE TABLE IF NOT EXISTS workflow_jobs (\n id TEXT PRIMARY KEY,\n run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,\n repo_id TEXT NOT NULL,\n job_key TEXT NOT NULL,\n name TEXT NOT NULL,\n runs_on TEXT NOT NULL,\n needs TEXT NOT NULL DEFAULT '[]',\n spec TEXT NOT NULL,\n status TEXT NOT NULL CHECK (status IN ('pending', 'queued', 'in_progress', 'completed')),\n conclusion TEXT CHECK (conclusion IN ('success', 'failure', 'cancelled', 'skipped')),\n runner_id TEXT,\n runner_name TEXT,\n created_at INTEGER NOT NULL,\n started_at INTEGER,\n completed_at INTEGER,\n outputs TEXT,\n environment TEXT,\n gate TEXT,\n UNIQUE (run_id, job_key)\n)", "CREATE INDEX IF NOT EXISTS workflow_jobs_queue ON workflow_jobs(status, created_at)", "CREATE INDEX IF NOT EXISTS workflow_jobs_runner ON workflow_jobs(runner_id, status)", "CREATE TABLE IF NOT EXISTS job_steps (\n job_id TEXT NOT NULL REFERENCES workflow_jobs(id) ON DELETE CASCADE,\n idx INTEGER NOT NULL,\n name TEXT NOT NULL,\n status TEXT NOT NULL CHECK (status IN ('pending', 'in_progress', 'completed')),\n conclusion TEXT CHECK (conclusion IN ('success', 'failure', 'cancelled', 'skipped')),\n started_at INTEGER,\n completed_at INTEGER,\n PRIMARY KEY (job_id, idx)\n)", "CREATE TABLE IF NOT EXISTS job_artifacts (\n id TEXT PRIMARY KEY,\n run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,\n job_id TEXT NOT NULL REFERENCES workflow_jobs(id) ON DELETE CASCADE,\n name TEXT NOT NULL,\n size INTEGER NOT NULL,\n r2_key TEXT NOT NULL,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS job_artifacts_run ON job_artifacts(run_id)", "CREATE TABLE IF NOT EXISTS commit_statuses (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n sha TEXT NOT NULL,\n context TEXT NOT NULL,\n state TEXT NOT NULL CHECK (state IN ('pending', 'success', 'failure', 'error')),\n description TEXT,\n target_url TEXT,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n workflow_path TEXT,\n workflow_hash TEXT,\n source TEXT CHECK (source IN ('ci', 'api')),\n UNIQUE (repo_id, sha, context)\n)", "CREATE TABLE IF NOT EXISTS releases (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n tag TEXT NOT NULL,\n name TEXT NOT NULL,\n body TEXT NOT NULL DEFAULT '',\n author_id TEXT NOT NULL,\n target_sha TEXT NOT NULL,\n draft INTEGER NOT NULL DEFAULT 0,\n prerelease INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n published_at INTEGER,\n UNIQUE (repo_id, tag)\n)", "CREATE TABLE IF NOT EXISTS release_assets (\n id TEXT PRIMARY KEY,\n release_id TEXT NOT NULL REFERENCES releases(id) ON DELETE CASCADE,\n name TEXT NOT NULL,\n size INTEGER NOT NULL,\n content_type TEXT NOT NULL,\n r2_key TEXT NOT NULL,\n download_count INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n UNIQUE (release_id, name)\n)", "CREATE TABLE IF NOT EXISTS activity (\n id TEXT PRIMARY KEY,\n actor_id TEXT,\n repo_id TEXT,\n kind TEXT NOT NULL,\n data TEXT NOT NULL DEFAULT '{}',\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS activity_repo ON activity(repo_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS activity_actor ON activity(actor_id, created_at DESC)", "CREATE TABLE IF NOT EXISTS push_events (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n ref TEXT NOT NULL,\n before_sha TEXT NOT NULL,\n after_sha TEXT NOT NULL,\n pusher_id TEXT,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS push_events_repo ON push_events(repo_id, created_at DESC)", "CREATE VIRTUAL TABLE IF NOT EXISTS issues_fts USING fts5(issue_id UNINDEXED, repo_id UNINDEXED, title, body)", "CREATE TABLE IF NOT EXISTS lfs_objects (\n repo_id TEXT NOT NULL,\n oid TEXT NOT NULL,\n owner_id TEXT NOT NULL,\n size INTEGER NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, oid)\n)", "CREATE INDEX IF NOT EXISTS lfs_objects_oid ON lfs_objects (oid)", "CREATE TABLE IF NOT EXISTS lfs_locks (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n path TEXT NOT NULL,\n ref_name TEXT,\n owner_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n UNIQUE (repo_id, path)\n)", "CREATE INDEX IF NOT EXISTS lfs_locks_repo_created ON lfs_locks (repo_id, created_at, id)", "CREATE TABLE IF NOT EXISTS deploy_tokens (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n name TEXT NOT NULL,\n token_hash TEXT NOT NULL UNIQUE,\n token_prefix TEXT NOT NULL,\n permission TEXT NOT NULL CHECK (permission IN ('read', 'write')),\n created_by TEXT,\n last_used_at INTEGER,\n expires_at INTEGER,\n created_at INTEGER NOT NULL\n, parent_token_id TEXT)", "CREATE INDEX IF NOT EXISTS deploy_tokens_repo ON deploy_tokens(repo_id)", "CREATE TABLE IF NOT EXISTS thread_subscriptions (\n user_id TEXT NOT NULL,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n subscribed INTEGER NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (user_id, issue_id)\n)", "CREATE INDEX IF NOT EXISTS thread_subscriptions_issue ON thread_subscriptions(issue_id)", "CREATE TABLE IF NOT EXISTS pull_auto_merges (\n issue_id TEXT PRIMARY KEY REFERENCES issues(id) ON DELETE CASCADE,\n repo_id TEXT NOT NULL,\n method TEXT NOT NULL CHECK (method IN ('merge', 'squash', 'rebase')),\n message TEXT NOT NULL DEFAULT '',\n enabled_by TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n head_sha TEXT\n)", "CREATE INDEX IF NOT EXISTS pull_auto_merges_repo ON pull_auto_merges(repo_id)", "CREATE TABLE IF NOT EXISTS merge_queue_entries (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n base_ref TEXT NOT NULL,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n method TEXT NOT NULL CHECK (method IN ('merge', 'squash')),\n state TEXT NOT NULL CHECK (state IN ('queued', 'testing', 'merged', 'failed', 'removed')),\n speculative_sha TEXT,\n base_sha TEXT,\n head_sha TEXT,\n error TEXT,\n enqueued_by TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS merge_queue_active ON merge_queue_entries(repo_id, base_ref, state, created_at)", "CREATE UNIQUE INDEX IF NOT EXISTS merge_queue_issue_active ON merge_queue_entries(issue_id) WHERE state IN ('queued', 'testing')", "CREATE INDEX IF NOT EXISTS merge_queue_speculative ON merge_queue_entries(repo_id, speculative_sha)", "CREATE TABLE IF NOT EXISTS pull_issue_links (\n pull_issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n source TEXT NOT NULL CHECK (source IN ('manual', 'keyword')),\n created_by TEXT,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (pull_issue_id, issue_id)\n)", "CREATE INDEX IF NOT EXISTS pull_issue_links_issue ON pull_issue_links(issue_id)", "CREATE TABLE IF NOT EXISTS milestones (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n title TEXT NOT NULL COLLATE NOCASE,\n description TEXT NOT NULL DEFAULT '',\n due_on INTEGER,\n state TEXT NOT NULL DEFAULT 'open' CHECK (state IN ('open', 'closed')),\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n UNIQUE (repo_id, title)\n)", "CREATE TABLE IF NOT EXISTS issue_types (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n name TEXT NOT NULL COLLATE NOCASE,\n color TEXT NOT NULL,\n description TEXT,\n UNIQUE (repo_id, name)\n)", "CREATE TABLE IF NOT EXISTS pinned_issues (\n repo_id TEXT NOT NULL,\n issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, issue_id)\n)", "CREATE TABLE IF NOT EXISTS issue_redirects (\n repo_id TEXT NOT NULL,\n number INTEGER NOT NULL,\n issue_id TEXT NOT NULL,\n PRIMARY KEY (repo_id, number)\n)", "CREATE TABLE IF NOT EXISTS reactions (\n subject_type TEXT NOT NULL,\n subject_id TEXT NOT NULL,\n user_id TEXT NOT NULL,\n content TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (subject_type, subject_id, user_id, content)\n)", "CREATE INDEX IF NOT EXISTS reactions_subject ON reactions(subject_type, subject_id)", "CREATE TABLE IF NOT EXISTS attachments (\n id TEXT PRIMARY KEY,\n owner_id TEXT NOT NULL,\n repo_id TEXT NOT NULL,\n uploader_id TEXT NOT NULL,\n name TEXT NOT NULL,\n content_type TEXT NOT NULL,\n size INTEGER NOT NULL,\n r2_key TEXT NOT NULL,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS attachments_owner ON attachments(owner_id)", "CREATE INDEX IF NOT EXISTS attachments_uploader ON attachments(uploader_id)", "CREATE TABLE IF NOT EXISTS discussion_categories (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n name TEXT NOT NULL COLLATE NOCASE,\n emoji TEXT NOT NULL DEFAULT '',\n description TEXT NOT NULL DEFAULT '',\n answerable INTEGER NOT NULL DEFAULT 0,\n UNIQUE (repo_id, name)\n)", "CREATE TABLE IF NOT EXISTS discussions (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n number INTEGER NOT NULL,\n category_id TEXT NOT NULL REFERENCES discussion_categories(id),\n author_id TEXT NOT NULL,\n title TEXT NOT NULL,\n body TEXT NOT NULL DEFAULT '',\n answer_id TEXT,\n upvotes INTEGER NOT NULL DEFAULT 0,\n comments_count INTEGER NOT NULL DEFAULT 0,\n locked INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n UNIQUE (repo_id, number)\n)", "CREATE INDEX IF NOT EXISTS discussions_repo ON discussions(repo_id, category_id, updated_at DESC)", "CREATE TABLE IF NOT EXISTS discussion_comments (\n id TEXT PRIMARY KEY,\n discussion_id TEXT NOT NULL REFERENCES discussions(id) ON DELETE CASCADE,\n parent_id TEXT REFERENCES discussion_comments(id) ON DELETE CASCADE,\n author_id TEXT NOT NULL,\n body TEXT NOT NULL,\n upvotes INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n, hidden_at INTEGER)", "CREATE INDEX IF NOT EXISTS discussion_comments_discussion ON discussion_comments(discussion_id, created_at)", "CREATE TABLE IF NOT EXISTS discussion_votes (\n subject_id TEXT NOT NULL,\n user_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (subject_id, user_id)\n)", "CREATE TABLE IF NOT EXISTS workflow_triggers (\n repo_id TEXT NOT NULL,\n workflow_path TEXT NOT NULL,\n workflow_name TEXT NOT NULL,\n events TEXT NOT NULL,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, workflow_path)\n)", "CREATE TABLE IF NOT EXISTS workflow_schedules (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n workflow_path TEXT NOT NULL,\n cron TEXT NOT NULL,\n next_run_at INTEGER NOT NULL,\n last_run_at INTEGER,\n UNIQUE (repo_id, workflow_path, cron)\n)", "CREATE INDEX IF NOT EXISTS workflow_schedules_due ON workflow_schedules(next_run_at)", "CREATE TABLE IF NOT EXISTS action_caches (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n ref TEXT NOT NULL,\n key TEXT NOT NULL,\n version TEXT NOT NULL,\n size INTEGER NOT NULL,\n r2_key TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n last_used_at INTEGER NOT NULL,\n content_sha256 TEXT,\n UNIQUE (repo_id, ref, key, version)\n)", "CREATE INDEX IF NOT EXISTS action_caches_lru ON action_caches(repo_id, last_used_at)", "CREATE INDEX IF NOT EXISTS action_caches_idle ON action_caches(last_used_at)", "CREATE INDEX IF NOT EXISTS action_caches_object ON action_caches(r2_key)", "CREATE TABLE IF NOT EXISTS repo_variables (\n repo_id TEXT NOT NULL,\n name TEXT NOT NULL,\n value TEXT NOT NULL,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, name)\n)", "CREATE TABLE IF NOT EXISTS environments (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n name TEXT NOT NULL,\n wait_timer_minutes INTEGER NOT NULL DEFAULT 0,\n reviewers TEXT NOT NULL DEFAULT '[]',\n branch_patterns TEXT NOT NULL DEFAULT '[]',\n prevent_self_review INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n UNIQUE (repo_id, name)\n)", "CREATE TABLE IF NOT EXISTS environment_secrets (\n environment_id TEXT NOT NULL REFERENCES environments(id) ON DELETE CASCADE,\n name TEXT NOT NULL,\n ciphertext TEXT NOT NULL,\n iv TEXT NOT NULL,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (environment_id, name)\n)", "CREATE TABLE IF NOT EXISTS environment_variables (\n environment_id TEXT NOT NULL REFERENCES environments(id) ON DELETE CASCADE,\n name TEXT NOT NULL,\n value TEXT NOT NULL,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (environment_id, name)\n)", "CREATE TABLE IF NOT EXISTS deployments (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n environment_id TEXT NOT NULL REFERENCES environments(id) ON DELETE CASCADE,\n run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,\n job_id TEXT NOT NULL UNIQUE REFERENCES workflow_jobs(id) ON DELETE CASCADE,\n ref TEXT NOT NULL,\n sha TEXT NOT NULL,\n creator_id TEXT,\n status TEXT NOT NULL CHECK (status IN ('waiting', 'queued', 'in_progress', 'success', 'failure', 'cancelled', 'rejected')),\n url TEXT,\n wait_until INTEGER,\n reviewed_by TEXT,\n reviewed_at INTEGER,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS deployments_repo ON deployments(repo_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS deployments_environment ON deployments(environment_id, created_at DESC)", "CREATE TABLE IF NOT EXISTS job_tokens (\n token_hash TEXT PRIMARY KEY,\n job_id TEXT NOT NULL REFERENCES workflow_jobs(id) ON DELETE CASCADE,\n repo_id TEXT NOT NULL,\n permissions TEXT NOT NULL,\n expires_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS job_tokens_job ON job_tokens(job_id)", "CREATE INDEX IF NOT EXISTS job_tokens_expiry ON job_tokens(expires_at)", "CREATE TABLE IF NOT EXISTS job_token_pushes (\n repo_id TEXT NOT NULL,\n sha TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, sha)\n)", "CREATE TABLE IF NOT EXISTS runner_policies (\n repo_id TEXT PRIMARY KEY,\n allow_fork_pull_requests INTEGER NOT NULL DEFAULT 0,\n updated_by TEXT,\n updated_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS repo_security_settings (\n repo_id TEXT PRIMARY KEY,\n secret_scanning INTEGER NOT NULL DEFAULT 1,\n push_protection INTEGER NOT NULL DEFAULT 0,\n private_reporting INTEGER NOT NULL DEFAULT 0,\n dependency_graph INTEGER NOT NULL DEFAULT 1,\n updated_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS secret_alerts (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n number INTEGER NOT NULL,\n detector TEXT NOT NULL,\n fingerprint TEXT NOT NULL,\n preview TEXT NOT NULL,\n path TEXT,\n line INTEGER,\n commit_sha TEXT,\n state TEXT NOT NULL DEFAULT 'open' CHECK (state IN ('open', 'resolved')),\n resolution TEXT CHECK (resolution IN ('revoked', 'false_positive', 'used_in_tests', 'wont_fix', 'bypassed')),\n resolved_by TEXT,\n resolved_at INTEGER,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n UNIQUE (repo_id, fingerprint),\n UNIQUE (repo_id, number)\n)", "CREATE INDEX IF NOT EXISTS secret_alerts_state ON secret_alerts(repo_id, state, created_at DESC)", "CREATE TABLE IF NOT EXISTS secret_push_blocks (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n user_id TEXT,\n detector TEXT NOT NULL,\n fingerprint TEXT NOT NULL,\n preview TEXT NOT NULL,\n blob_sha TEXT,\n bypassed_at INTEGER,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS secret_push_blocks_repo ON secret_push_blocks(repo_id, created_at DESC)", "CREATE TABLE IF NOT EXISTS security_advisories (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n ghsa_id TEXT NOT NULL UNIQUE,\n title TEXT NOT NULL,\n description TEXT NOT NULL,\n severity TEXT NOT NULL CHECK (severity IN ('low', 'moderate', 'high', 'critical')),\n cve_id TEXT,\n cwe_ids TEXT,\n ecosystem TEXT,\n package_name TEXT,\n affected_versions TEXT,\n patched_versions TEXT,\n state TEXT NOT NULL CHECK (state IN ('triage', 'draft', 'published', 'closed')),\n source TEXT NOT NULL CHECK (source IN ('maintainer', 'report')),\n author_id TEXT,\n published_at INTEGER,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS security_advisories_repo ON security_advisories(repo_id, state, updated_at DESC)", "CREATE INDEX IF NOT EXISTS security_advisories_package ON security_advisories(ecosystem, package_name, state)", "CREATE TABLE IF NOT EXISTS advisory_collaborators (\n advisory_id TEXT NOT NULL REFERENCES security_advisories(id) ON DELETE CASCADE,\n user_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (advisory_id, user_id)\n)", "CREATE TABLE IF NOT EXISTS advisory_comments (\n id TEXT PRIMARY KEY,\n advisory_id TEXT NOT NULL REFERENCES security_advisories(id) ON DELETE CASCADE,\n author_id TEXT,\n body TEXT NOT NULL,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS advisory_comments_advisory ON advisory_comments(advisory_id, created_at)", "CREATE TABLE IF NOT EXISTS sarif_uploads (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n uploader_id TEXT,\n commit_sha TEXT NOT NULL,\n ref TEXT NOT NULL,\n r2_key TEXT NOT NULL,\n size INTEGER NOT NULL,\n status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'complete', 'failed')),\n error TEXT,\n tools TEXT,\n results_count INTEGER,\n created_at INTEGER NOT NULL,\n processed_at INTEGER\n)", "CREATE INDEX IF NOT EXISTS sarif_uploads_repo ON sarif_uploads(repo_id, created_at DESC)", "CREATE TABLE IF NOT EXISTS code_scanning_alerts (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n number INTEGER NOT NULL,\n ref TEXT NOT NULL,\n tool TEXT NOT NULL,\n rule_id TEXT NOT NULL,\n rule_name TEXT,\n severity TEXT NOT NULL CHECK (severity IN ('error', 'warning', 'note', 'none')),\n security_severity TEXT,\n message TEXT NOT NULL,\n path TEXT,\n start_line INTEGER,\n end_line INTEGER,\n commit_sha TEXT NOT NULL,\n fingerprint TEXT NOT NULL,\n state TEXT NOT NULL DEFAULT 'open' CHECK (state IN ('open', 'fixed', 'dismissed')),\n dismissed_reason TEXT,\n dismissed_by TEXT,\n last_upload_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n UNIQUE (repo_id, ref, tool, fingerprint),\n UNIQUE (repo_id, number)\n)", "CREATE INDEX IF NOT EXISTS code_scanning_alerts_ref ON code_scanning_alerts(repo_id, ref, state)", "CREATE INDEX IF NOT EXISTS code_scanning_alerts_commit ON code_scanning_alerts(repo_id, commit_sha)", "CREATE TABLE IF NOT EXISTS security_counters (\n repo_id TEXT NOT NULL,\n kind TEXT NOT NULL,\n next_number INTEGER NOT NULL,\n PRIMARY KEY (repo_id, kind)\n)", "CREATE TABLE IF NOT EXISTS dependency_manifests (\n repo_id TEXT NOT NULL,\n path TEXT NOT NULL,\n ecosystem TEXT NOT NULL,\n commit_sha TEXT NOT NULL,\n dependency_count INTEGER NOT NULL,\n scanned_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, path)\n)", "CREATE TABLE IF NOT EXISTS dependencies (\n repo_id TEXT NOT NULL,\n manifest_path TEXT NOT NULL,\n ecosystem TEXT NOT NULL,\n name TEXT NOT NULL,\n requirement TEXT,\n scope TEXT NOT NULL CHECK (scope IN ('runtime', 'development')),\n direct INTEGER NOT NULL,\n PRIMARY KEY (repo_id, manifest_path, name, scope)\n)", "CREATE INDEX IF NOT EXISTS dependencies_package ON dependencies(ecosystem, name)", "CREATE TABLE IF NOT EXISTS hidden_ref_cleanups (\n repo_id TEXT PRIMARY KEY,\n attempts INTEGER NOT NULL DEFAULT 0,\n requested_at INTEGER NOT NULL,\n next_attempt_at INTEGER NOT NULL DEFAULT 0\n, cursor TEXT)", "CREATE TABLE IF NOT EXISTS sites (\n id TEXT PRIMARY KEY,\n owner_id TEXT,\n repo_id TEXT UNIQUE,\n label TEXT NOT NULL UNIQUE,\n source TEXT NOT NULL CHECK (source IN ('branch', 'workflow', 'upload')),\n branch TEXT NOT NULL DEFAULT 'main',\n folder TEXT NOT NULL DEFAULT '',\n artifact_name TEXT NOT NULL DEFAULT 'site',\n spa INTEGER NOT NULL DEFAULT 0,\n previews INTEGER NOT NULL DEFAULT 1,\n access TEXT NOT NULL DEFAULT 'public' CHECK (access IN ('public', 'password', 'gitfor', 'oidc')),\n audience TEXT NOT NULL DEFAULT 'readers' CHECK (audience IN ('readers', 'members')),\n password_hash TEXT,\n oidc_issuer TEXT,\n oidc_client_id TEXT,\n oidc_secret_ct TEXT,\n oidc_secret_iv TEXT,\n oidc_allowed TEXT,\n access_version INTEGER NOT NULL DEFAULT 1,\n env_version INTEGER NOT NULL DEFAULT 1,\n custom_domain TEXT UNIQUE,\n custom_hostname_id TEXT,\n domain_status TEXT,\n domain_claimed_at INTEGER,\n domain_token TEXT,\n active_deployment_id TEXT,\n scratch INTEGER NOT NULL DEFAULT 0,\n claim_token_hash TEXT,\n creator_ip_hash TEXT,\n expires_at INTEGER,\n disabled_reason TEXT,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n domain_checked_at INTEGER,\n push_token_hash TEXT\n, preview_env INTEGER NOT NULL DEFAULT 0, paused_at INTEGER, commit_previews INTEGER NOT NULL DEFAULT 0, domain_verified_at INTEGER)", "CREATE INDEX IF NOT EXISTS sites_scratch_expiry ON sites(scratch, expires_at)", "CREATE INDEX IF NOT EXISTS sites_creator_ip ON sites(creator_ip_hash, created_at)", "CREATE INDEX IF NOT EXISTS sites_push_token ON sites(push_token_hash)", "CREATE TABLE IF NOT EXISTS site_deployments (\n id TEXT PRIMARY KEY,\n site_id TEXT NOT NULL REFERENCES sites(id) ON DELETE CASCADE,\n environment TEXT NOT NULL CHECK (environment IN ('production', 'preview')),\n label TEXT NOT NULL,\n branch TEXT,\n source TEXT NOT NULL CHECK (source IN ('branch', 'artifact', 'upload')),\n ref TEXT NOT NULL,\n sha TEXT NOT NULL,\n artifact_id TEXT,\n kind TEXT NOT NULL DEFAULT 'static' CHECK (kind IN ('static', 'worker')),\n status TEXT NOT NULL CHECK (status IN ('queued', 'building', 'active', 'failed', 'superseded')),\n file_count INTEGER NOT NULL DEFAULT 0,\n total_bytes INTEGER NOT NULL DEFAULT 0,\n error TEXT,\n creator_id TEXT,\n created_at INTEGER NOT NULL,\n completed_at INTEGER\n, creator_admin INTEGER NOT NULL DEFAULT 0)", "CREATE INDEX IF NOT EXISTS site_deployments_site ON site_deployments(site_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS site_deployments_label ON site_deployments(label, status)", "CREATE TABLE IF NOT EXISTS site_env (\n site_id TEXT NOT NULL REFERENCES sites(id) ON DELETE CASCADE,\n name TEXT NOT NULL,\n secret INTEGER NOT NULL DEFAULT 0,\n value_ct TEXT NOT NULL,\n value_iv TEXT NOT NULL,\n updated_at INTEGER NOT NULL, preview INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (site_id, name)\n)", "CREATE TABLE IF NOT EXISTS site_preview_comments (\n site_id TEXT NOT NULL REFERENCES sites(id) ON DELETE CASCADE,\n pr_number INTEGER NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (site_id, pr_number)\n)", "CREATE TABLE IF NOT EXISTS site_usage (\n site_id TEXT NOT NULL REFERENCES sites(id) ON DELETE CASCADE,\n day TEXT NOT NULL,\n account_id TEXT,\n requests INTEGER NOT NULL DEFAULT 0,\n cpu_ms INTEGER NOT NULL DEFAULT 0,\n bytes_out INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (site_id, day)\n)", "CREATE INDEX IF NOT EXISTS site_usage_account ON site_usage(account_id, day)", "CREATE TABLE IF NOT EXISTS repo_mergefix_settings (\n repo_id TEXT PRIMARY KEY,\n queue_enabled INTEGER NOT NULL DEFAULT 0,\n allow_private INTEGER NOT NULL DEFAULT 0,\n min_confidence REAL NOT NULL DEFAULT 0.8,\n min_margin REAL NOT NULL DEFAULT 0.3,\n updated_at INTEGER NOT NULL\n, auto_apply INTEGER NOT NULL DEFAULT 0)", "CREATE TABLE IF NOT EXISTS mergefix_runs (\n id TEXT PRIMARY KEY,\n pull_issue_id TEXT NOT NULL REFERENCES issues(id) ON DELETE CASCADE,\n repo_id TEXT NOT NULL,\n account_id TEXT NOT NULL,\n actor_id TEXT NOT NULL,\n trigger TEXT NOT NULL CHECK (trigger IN ('button', 'queue')),\n status TEXT NOT NULL CHECK (status IN ('queued', 'running', 'applying', 'applied', 'suggested', 'failed')),\n head_sha TEXT NOT NULL,\n base_sha TEXT,\n commit_sha TEXT,\n calls INTEGER NOT NULL DEFAULT 0,\n result_json TEXT,\n error TEXT,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n queue_method TEXT CHECK (queue_method IN ('merge', 'squash')),\n requeue_status TEXT CHECK (requeue_status IN ('waiting', 'enqueued', 'gave_up')),\n requeue_attempts INTEGER NOT NULL DEFAULT 0,\n requeue_error TEXT\n, mode TEXT NOT NULL DEFAULT 'auto' CHECK (mode IN ('propose', 'auto')), stale INTEGER NOT NULL DEFAULT 0, applied_by TEXT, applied_files TEXT)", "CREATE INDEX IF NOT EXISTS mergefix_runs_pull ON mergefix_runs (pull_issue_id, created_at DESC)", "CREATE UNIQUE INDEX IF NOT EXISTS mergefix_runs_one_active ON mergefix_runs (pull_issue_id) WHERE status IN ('queued', 'running', 'applying')", "CREATE TABLE IF NOT EXISTS repo_storage_estimates (\n repo_id TEXT PRIMARY KEY,\n pack_bytes INTEGER NOT NULL DEFAULT 0,\n updated_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS ci_notify_state (\n repo_id TEXT NOT NULL,\n workflow_path TEXT NOT NULL,\n ref TEXT NOT NULL,\n conclusion TEXT NOT NULL,\n last_run_id TEXT,\n previous_conclusion TEXT,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (repo_id, workflow_path, ref)\n)", "CREATE INDEX IF NOT EXISTS deploy_tokens_parent ON deploy_tokens(parent_token_id)", "CREATE INDEX IF NOT EXISTS attachments_created ON attachments(created_at)", "CREATE INDEX IF NOT EXISTS webhook_deliveries_created ON webhook_deliveries(created_at)", "CREATE INDEX IF NOT EXISTS reactions_listing ON reactions(subject_type, subject_id, content, created_at)", "CREATE INDEX IF NOT EXISTS deploy_tokens_creator ON deploy_tokens(created_by)", "CREATE INDEX IF NOT EXISTS pull_requests_bridged ON pull_requests(head_repo_id) WHERE bridged_bytes > 0", "CREATE INDEX IF NOT EXISTS pull_requests_stacked_on ON pull_requests(stacked_on_issue_id) WHERE stacked_on_issue_id IS NOT NULL", "CREATE TABLE IF NOT EXISTS \"site_pr_aliases\" (\n site_id TEXT NOT NULL REFERENCES sites(id) ON DELETE CASCADE,\n label TEXT NOT NULL,\n pr_number INTEGER NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('pr', 'commit')),\n deployment_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (site_id, label, pr_number)\n)", "CREATE INDEX IF NOT EXISTS site_pr_aliases_pull ON site_pr_aliases(site_id, pr_number, kind, created_at)", "CREATE INDEX IF NOT EXISTS site_pr_aliases_label ON site_pr_aliases(label)" ]; export const ACCOUNT_SCHEMA: readonly string[] = [ "CREATE TABLE IF NOT EXISTS access_tokens (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n name TEXT NOT NULL,\n token_hash TEXT NOT NULL UNIQUE,\n token_prefix TEXT NOT NULL,\n scopes TEXT NOT NULL,\n last_used_at INTEGER,\n expires_at INTEGER,\n created_at INTEGER NOT NULL,\n permissions TEXT,\n all_repos INTEGER NOT NULL DEFAULT 1,\n audience TEXT\n, parent_token_id TEXT)", "CREATE INDEX IF NOT EXISTS access_tokens_user ON access_tokens(user_id)", "CREATE TABLE IF NOT EXISTS runners (\n id TEXT PRIMARY KEY,\n repo_id TEXT,\n owner_id TEXT,\n name TEXT NOT NULL,\n labels TEXT NOT NULL,\n token_hash TEXT NOT NULL UNIQUE,\n last_seen_at INTEGER,\n created_at INTEGER NOT NULL,\n os TEXT NOT NULL DEFAULT '',\n arch TEXT NOT NULL DEFAULT '',\n version TEXT NOT NULL DEFAULT '',\n isolation TEXT NOT NULL DEFAULT 'none',\n max_jobs INTEGER NOT NULL DEFAULT 1,\n previous_token_hash TEXT,\n previous_token_expires_at INTEGER,\n token_rotated_at INTEGER,\n token_confirmed INTEGER NOT NULL DEFAULT 1,\n isolation_attested INTEGER NOT NULL DEFAULT 0\n)", "CREATE INDEX IF NOT EXISTS runners_previous_token ON runners(previous_token_hash)", "CREATE INDEX IF NOT EXISTS runners_repo ON runners(repo_id)", "CREATE INDEX IF NOT EXISTS runners_owner ON runners(owner_id)", "CREATE TABLE IF NOT EXISTS notifications (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n repo_id TEXT,\n reason TEXT NOT NULL,\n title TEXT NOT NULL,\n url TEXT NOT NULL,\n read_at INTEGER,\n created_at INTEGER NOT NULL,\n category TEXT\n)", "CREATE INDEX IF NOT EXISTS notifications_user ON notifications(user_id, read_at, created_at DESC)", "CREATE TABLE IF NOT EXISTS lfs_usage (\n owner_id TEXT PRIMARY KEY,\n storage_bytes INTEGER NOT NULL DEFAULT 0,\n bandwidth_period TEXT NOT NULL DEFAULT '',\n bandwidth_bytes INTEGER NOT NULL DEFAULT 0\n)", "CREATE TABLE IF NOT EXISTS lfs_account_objects (\n owner_id TEXT NOT NULL,\n oid TEXT NOT NULL,\n size INTEGER NOT NULL,\n refs INTEGER NOT NULL,\n PRIMARY KEY (owner_id, oid)\n)", "CREATE TABLE IF NOT EXISTS recovery_codes (\n user_id TEXT NOT NULL,\n code_hash TEXT NOT NULL,\n used_at INTEGER,\n PRIMARY KEY (user_id, code_hash)\n)", "CREATE TABLE IF NOT EXISTS passkeys (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n name TEXT NOT NULL,\n public_key TEXT NOT NULL,\n algorithm INTEGER NOT NULL,\n sign_count INTEGER NOT NULL DEFAULT 0,\n transports TEXT NOT NULL DEFAULT '[]',\n last_used_at INTEGER,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS passkeys_user ON passkeys(user_id)", "CREATE TABLE IF NOT EXISTS access_token_repos (\n token_id TEXT NOT NULL REFERENCES access_tokens(id) ON DELETE CASCADE,\n repo_id TEXT NOT NULL,\n PRIMARY KEY (token_id, repo_id)\n)", "CREATE INDEX IF NOT EXISTS access_token_repos_repo ON access_token_repos(repo_id)", "CREATE TABLE IF NOT EXISTS notification_settings (\n user_id TEXT PRIMARY KEY,\n email_participating INTEGER NOT NULL DEFAULT 1,\n email_watching INTEGER NOT NULL DEFAULT 0,\n web_participating INTEGER NOT NULL DEFAULT 1,\n web_watching INTEGER NOT NULL DEFAULT 1,\n updated_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS auth_tokens (\n token_hash TEXT PRIMARY KEY,\n kind TEXT NOT NULL,\n user_id TEXT,\n payload TEXT NOT NULL DEFAULT '{}',\n attempts INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL,\n expires_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS auth_tokens_user ON auth_tokens(user_id, kind)", "CREATE INDEX IF NOT EXISTS auth_tokens_expiry ON auth_tokens(expires_at)", "CREATE TABLE IF NOT EXISTS projects (\n id TEXT PRIMARY KEY,\n owner_id TEXT NOT NULL,\n number INTEGER NOT NULL,\n title TEXT NOT NULL,\n description TEXT NOT NULL DEFAULT '',\n visibility TEXT NOT NULL DEFAULT 'private' CHECK (visibility IN ('public', 'private')),\n closed INTEGER NOT NULL DEFAULT 0,\n created_by TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n UNIQUE (owner_id, number)\n)", "CREATE TABLE IF NOT EXISTS project_fields (\n id TEXT PRIMARY KEY,\n project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,\n name TEXT NOT NULL COLLATE NOCASE,\n kind TEXT NOT NULL CHECK (kind IN ('text', 'number', 'date', 'single_select')),\n options TEXT NOT NULL DEFAULT '[]',\n position INTEGER NOT NULL,\n UNIQUE (project_id, name)\n)", "CREATE TABLE IF NOT EXISTS project_items (\n id TEXT PRIMARY KEY,\n project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,\n issue_id TEXT,\n note TEXT,\n position REAL NOT NULL,\n created_at INTEGER NOT NULL,\n UNIQUE (project_id, issue_id)\n)", "CREATE INDEX IF NOT EXISTS project_items_issue ON project_items(issue_id)", "CREATE TABLE IF NOT EXISTS project_item_values (\n item_id TEXT NOT NULL REFERENCES project_items(id) ON DELETE CASCADE,\n field_id TEXT NOT NULL REFERENCES project_fields(id) ON DELETE CASCADE,\n value TEXT NOT NULL,\n PRIMARY KEY (item_id, field_id)\n)", "CREATE TABLE IF NOT EXISTS owner_secrets (\n owner_id TEXT NOT NULL,\n name TEXT NOT NULL,\n ciphertext TEXT NOT NULL,\n iv TEXT NOT NULL,\n visibility TEXT NOT NULL CHECK (visibility IN ('all', 'private', 'selected')),\n selected_repos TEXT NOT NULL DEFAULT '[]',\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (owner_id, name)\n)", "CREATE TABLE IF NOT EXISTS owner_variables (\n owner_id TEXT NOT NULL,\n name TEXT NOT NULL,\n value TEXT NOT NULL,\n visibility TEXT NOT NULL CHECK (visibility IN ('all', 'private', 'selected')),\n selected_repos TEXT NOT NULL DEFAULT '[]',\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (owner_id, name)\n)", "CREATE TABLE IF NOT EXISTS runner_registration_tokens (\n token_hash TEXT PRIMARY KEY,\n repo_id TEXT,\n owner_id TEXT,\n created_by TEXT NOT NULL,\n labels TEXT NOT NULL DEFAULT '[]',\n expires_at INTEGER NOT NULL,\n used_at INTEGER,\n created_at INTEGER NOT NULL,\n isolation TEXT NOT NULL DEFAULT 'container',\n CHECK ((repo_id IS NULL) != (owner_id IS NULL))\n)", "CREATE INDEX IF NOT EXISTS runner_registration_tokens_expiry ON runner_registration_tokens(expires_at)", "CREATE INDEX IF NOT EXISTS runner_registration_tokens_repo ON runner_registration_tokens(repo_id)", "CREATE INDEX IF NOT EXISTS runner_registration_tokens_owner ON runner_registration_tokens(owner_id)", "CREATE TABLE IF NOT EXISTS runner_usage_events (\n id TEXT PRIMARY KEY,\n owner_id TEXT NOT NULL,\n repo_id TEXT,\n kind TEXT NOT NULL CHECK (kind IN ('self_hosted_runner_ms', 'cache_bytes_stored', 'cache_bytes_freed')),\n quantity INTEGER NOT NULL,\n subject_id TEXT,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS runner_usage_events_owner ON runner_usage_events(owner_id, created_at)", "CREATE TABLE IF NOT EXISTS \"signing_keys\" (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('ssh', 'gpg')),\n title TEXT NOT NULL,\n fingerprint TEXT NOT NULL,\n public_key TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n UNIQUE (user_id, kind, fingerprint)\n)", "CREATE INDEX IF NOT EXISTS signing_keys_user ON signing_keys(user_id)", "CREATE INDEX IF NOT EXISTS signing_keys_fingerprint ON signing_keys(kind, fingerprint)", "CREATE TABLE IF NOT EXISTS editor_container_sessions (\n id TEXT PRIMARY KEY,\n account_id TEXT NOT NULL,\n repo_id TEXT NOT NULL,\n branch TEXT NOT NULL,\n instance_type TEXT NOT NULL,\n started_at INTEGER NOT NULL,\n stopped_at INTEGER,\n minutes INTEGER,\n stop_reason TEXT\n)", "CREATE INDEX IF NOT EXISTS editor_container_sessions_account ON editor_container_sessions(account_id, started_at)", "CREATE INDEX IF NOT EXISTS editor_container_sessions_open ON editor_container_sessions(stopped_at) WHERE stopped_at IS NULL", "CREATE TABLE IF NOT EXISTS integration_usage_daily (\n owner_id TEXT NOT NULL,\n day TEXT NOT NULL,\n kind TEXT NOT NULL,\n deliveries INTEGER NOT NULL DEFAULT 0,\n failures INTEGER NOT NULL DEFAULT 0,\n bytes INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (owner_id, day, kind)\n)", "CREATE TABLE IF NOT EXISTS oauth_codes (\n code_hash TEXT PRIMARY KEY,\n client_id TEXT NOT NULL,\n user_id TEXT NOT NULL,\n redirect_uri TEXT NOT NULL,\n code_challenge TEXT NOT NULL,\n resource TEXT NOT NULL,\n -- JSON: { permissions, allRepos, repoIds, agent }\n grant_json TEXT NOT NULL,\n expires_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS oauth_refresh_tokens (\n token_hash TEXT PRIMARY KEY,\n client_id TEXT NOT NULL,\n user_id TEXT NOT NULL,\n access_token_id TEXT NOT NULL REFERENCES access_tokens(id) ON DELETE CASCADE,\n resource TEXT NOT NULL,\n grant_json TEXT NOT NULL,\n expires_at INTEGER NOT NULL,\n used_at INTEGER,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS oauth_refresh_tokens_user ON oauth_refresh_tokens(user_id)", "CREATE INDEX IF NOT EXISTS oauth_refresh_tokens_access ON oauth_refresh_tokens(access_token_id)", "CREATE TABLE IF NOT EXISTS mcp_token_agents (\n token_id TEXT PRIMARY KEY REFERENCES access_tokens(id) ON DELETE CASCADE,\n agent_name TEXT NOT NULL,\n client_id TEXT,\n authorized_by TEXT NOT NULL,\n parent_token_id TEXT,\n created_at INTEGER NOT NULL,\n agent_id TEXT REFERENCES agents(id) ON DELETE CASCADE,\n kind TEXT NOT NULL DEFAULT 'oauth'\n)", "CREATE INDEX IF NOT EXISTS mcp_token_agents_parent ON mcp_token_agents(parent_token_id)", "CREATE INDEX IF NOT EXISTS mcp_token_agents_agent ON mcp_token_agents(agent_id)", "CREATE TABLE IF NOT EXISTS mcp_audit (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n token_id TEXT,\n agent_name TEXT,\n repo_id TEXT,\n tool TEXT NOT NULL,\n arguments TEXT NOT NULL,\n outcome TEXT NOT NULL CHECK (outcome IN ('ok', 'denied', 'error')),\n detail TEXT,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS mcp_audit_user ON mcp_audit(user_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS mcp_audit_repo ON mcp_audit(repo_id, created_at DESC)", "CREATE TABLE IF NOT EXISTS agents (\n id TEXT PRIMARY KEY,\n owner_id TEXT NOT NULL,\n name TEXT NOT NULL COLLATE NOCASE,\n description TEXT,\n created_at INTEGER NOT NULL,\n UNIQUE (owner_id, name)\n)", "CREATE TRIGGER IF NOT EXISTS agents_revoke_tokens BEFORE DELETE ON agents\nBEGIN\n DELETE FROM access_tokens WHERE id IN (SELECT token_id FROM mcp_token_agents WHERE agent_id = OLD.id);\nEND", "CREATE TABLE IF NOT EXISTS mcp_usage_daily (\n account_id TEXT NOT NULL,\n day TEXT NOT NULL,\n tool TEXT NOT NULL,\n calls INTEGER NOT NULL DEFAULT 0,\n errors INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (account_id, day, tool)\n)", "CREATE TABLE IF NOT EXISTS usage_events (\n idempotency_key TEXT PRIMARY KEY,\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n period TEXT NOT NULL,\n quantity REAL NOT NULL,\n repo_id TEXT,\n attributes TEXT,\n created_at INTEGER NOT NULL\n, nonce TEXT)", "CREATE INDEX IF NOT EXISTS usage_events_account ON usage_events (account_id, period, meter)", "CREATE INDEX IF NOT EXISTS usage_events_created ON usage_events (created_at)", "CREATE TRIGGER IF NOT EXISTS usage_events_rollup AFTER INSERT ON usage_events\nBEGIN\n INSERT INTO usage_periods (account_id, meter, period, quantity, updated_at)\n VALUES (NEW.account_id, NEW.meter, NEW.period, NEW.quantity, NEW.created_at)\n ON CONFLICT (account_id, meter, period) DO UPDATE SET quantity = quantity + excluded.quantity,\n updated_at = excluded.updated_at;\n INSERT INTO usage_days (account_id, meter, day, quantity)\n VALUES (NEW.account_id, NEW.meter, strftime('%Y-%m-%d', NEW.created_at / 1000, 'unixepoch'), NEW.quantity)\n ON CONFLICT (account_id, meter, day) DO UPDATE SET quantity = quantity + excluded.quantity;\nEND", "CREATE TRIGGER IF NOT EXISTS usage_events_repo_rollup AFTER INSERT ON usage_events WHEN NEW.repo_id IS NOT NULL\nBEGIN\n INSERT INTO usage_repo_periods (account_id, repo_id, meter, period, quantity)\n VALUES (NEW.account_id, NEW.repo_id, NEW.meter, NEW.period, NEW.quantity)\n ON CONFLICT (account_id, repo_id, meter, period) DO UPDATE SET quantity = quantity + excluded.quantity;\nEND", "CREATE TABLE IF NOT EXISTS usage_periods (\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n period TEXT NOT NULL,\n quantity REAL NOT NULL DEFAULT 0,\n reserved REAL NOT NULL DEFAULT 0,\n updated_at INTEGER NOT NULL DEFAULT 0, credit_covered REAL NOT NULL DEFAULT 0,\n PRIMARY KEY (account_id, meter, period)\n)", "CREATE TABLE IF NOT EXISTS usage_repo_periods (\n account_id TEXT NOT NULL,\n repo_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n period TEXT NOT NULL,\n quantity REAL NOT NULL DEFAULT 0,\n PRIMARY KEY (account_id, repo_id, meter, period)\n)", "CREATE TABLE IF NOT EXISTS usage_days (\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n day TEXT NOT NULL,\n quantity REAL NOT NULL DEFAULT 0,\n PRIMARY KEY (account_id, meter, day)\n)", "CREATE TABLE IF NOT EXISTS usage_reservations (\n id TEXT PRIMARY KEY,\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n period TEXT NOT NULL,\n quantity REAL NOT NULL,\n expires_at INTEGER NOT NULL,\n created_at INTEGER NOT NULL,\n nonce TEXT\n)", "CREATE INDEX IF NOT EXISTS usage_reservations_expiry ON usage_reservations (expires_at)", "CREATE TABLE IF NOT EXISTS usage_gauges (\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n period TEXT NOT NULL,\n current REAL NOT NULL DEFAULT 0,\n peak REAL NOT NULL DEFAULT 0,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (account_id, meter, period)\n)", "CREATE TABLE IF NOT EXISTS account_billing (\n account_id TEXT PRIMARY KEY,\n plan TEXT NOT NULL DEFAULT 'free',\n spending_limit_cents INTEGER,\n updated_at INTEGER NOT NULL\n, plan_override INTEGER NOT NULL DEFAULT 0, custom_domains_grant INTEGER NOT NULL DEFAULT 0, hosting_suspended_at INTEGER)", "CREATE TABLE IF NOT EXISTS usage_alerts (\n account_id TEXT NOT NULL,\n period TEXT NOT NULL,\n subject TEXT NOT NULL,\n threshold INTEGER NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (account_id, period, subject, threshold)\n)", "CREATE TABLE IF NOT EXISTS usage_claims (\n scratch_id TEXT PRIMARY KEY,\n account_id TEXT NOT NULL,\n claimed_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS notification_category_prefs (\n user_id TEXT NOT NULL,\n category TEXT NOT NULL,\n web INTEGER NOT NULL,\n email INTEGER NOT NULL,\n digest TEXT NOT NULL DEFAULT 'off',\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (user_id, category)\n)", "CREATE TABLE IF NOT EXISTS notification_digest_items (\n id TEXT PRIMARY KEY,\n user_id TEXT NOT NULL,\n repo_id TEXT,\n category TEXT NOT NULL,\n title TEXT NOT NULL,\n url TEXT NOT NULL,\n account_id TEXT,\n subject TEXT,\n access TEXT NOT NULL,\n flush_after INTEGER NOT NULL,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS notification_digest_items_user ON notification_digest_items(user_id, category, created_at)", "CREATE INDEX IF NOT EXISTS notification_digest_items_flush ON notification_digest_items(flush_after)", "CREATE TABLE IF NOT EXISTS notification_email_counters (\n user_id TEXT NOT NULL,\n window_start INTEGER NOT NULL,\n sent INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (user_id, window_start)\n)", "CREATE TABLE IF NOT EXISTS notification_unsubscribe_tokens (\n user_id TEXT PRIMARY KEY,\n token TEXT NOT NULL UNIQUE,\n created_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS security_managers (\n account_id TEXT NOT NULL,\n user_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (account_id, user_id)\n)", "CREATE TABLE IF NOT EXISTS notification_deliveries (\n message_id TEXT NOT NULL,\n user_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (message_id, user_id)\n)", "CREATE INDEX IF NOT EXISTS notification_deliveries_created ON notification_deliveries(created_at)", "CREATE TABLE IF NOT EXISTS quota_notices (\n account_id TEXT NOT NULL,\n metric TEXT NOT NULL,\n period TEXT NOT NULL,\n threshold INTEGER NOT NULL,\n notified_at INTEGER NOT NULL,\n PRIMARY KEY (account_id, metric, period, threshold)\n)", "CREATE INDEX IF NOT EXISTS access_tokens_parent ON access_tokens(parent_token_id)", "CREATE TABLE IF NOT EXISTS sessions (\n token_hash TEXT PRIMARY KEY,\n id TEXT NOT NULL UNIQUE,\n user_id TEXT NOT NULL,\n ip TEXT,\n user_agent TEXT,\n created_at INTEGER NOT NULL,\n last_seen_at INTEGER NOT NULL,\n expires_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS sessions_user ON sessions(user_id)", "CREATE INDEX IF NOT EXISTS sessions_expiry ON sessions(expires_at)", "CREATE TABLE IF NOT EXISTS org_invitations (\n id TEXT PRIMARY KEY,\n org_id TEXT NOT NULL,\n user_id TEXT NOT NULL,\n role TEXT NOT NULL CHECK (role IN ('owner', 'member')),\n invited_by TEXT,\n created_at INTEGER NOT NULL,\n expires_at INTEGER NOT NULL,\n UNIQUE (org_id, user_id)\n)", "CREATE INDEX IF NOT EXISTS org_invitations_user ON org_invitations(user_id, expires_at)", "CREATE INDEX IF NOT EXISTS org_invitations_expires ON org_invitations(expires_at)", "CREATE INDEX IF NOT EXISTS oauth_codes_expires ON oauth_codes(expires_at)", "CREATE INDEX IF NOT EXISTS oauth_refresh_tokens_expires ON oauth_refresh_tokens(expires_at)", "CREATE INDEX IF NOT EXISTS editor_container_sessions_account_open\n ON editor_container_sessions(account_id) WHERE stopped_at IS NULL", "CREATE TRIGGER IF NOT EXISTS access_tokens_permissions_required_insert BEFORE INSERT ON access_tokens\nWHEN NEW.permissions IS NULL\nBEGIN\n SELECT RAISE(ABORT, 'access_tokens.permissions is required: classic tokens no longer exist');\nEND", "CREATE TRIGGER IF NOT EXISTS access_tokens_permissions_required_update BEFORE UPDATE OF permissions ON access_tokens\nWHEN NEW.permissions IS NULL\nBEGIN\n SELECT RAISE(ABORT, 'access_tokens.permissions is required: classic tokens no longer exist');\nEND", "CREATE TABLE IF NOT EXISTS billing_customers (\n account_id TEXT PRIMARY KEY,\n stripe_customer_id TEXT NOT NULL UNIQUE,\n subscription_id TEXT,\n subscription_status TEXT,\n price_id TEXT,\n current_period_end INTEGER,\n -- created time (ms) of the newest subscription event applied, so out-of-order deliveries never regress state.\n subscription_event_at INTEGER NOT NULL DEFAULT 0,\n cancel_at_period_end INTEGER NOT NULL DEFAULT 0,\n updated_at INTEGER NOT NULL\n, past_due_since INTEGER)", "CREATE TABLE IF NOT EXISTS credit_balances (\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n balance REAL NOT NULL DEFAULT 0 CHECK (balance >= 0),\n updated_at INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (account_id, meter)\n)", "CREATE TABLE IF NOT EXISTS credit_ledger (\n ref TEXT PRIMARY KEY,\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('purchase', 'refund', 'dispute', 'adjust')),\n quantity REAL NOT NULL,\n -- For reversals: the amount owed back before clamping to the unspent balance, so later reversals of the\n -- same purchase never take more than their own share.\n requested REAL,\n -- For reversals: the purchase (its ref) being reversed.\n purchase_ref TEXT,\n pack TEXT,\n payment_intent TEXT,\n amount_cents INTEGER,\n nonce TEXT,\n created_at INTEGER NOT NULL\n)", "CREATE INDEX IF NOT EXISTS credit_ledger_account ON credit_ledger (account_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS credit_ledger_payment ON credit_ledger (payment_intent)", "CREATE TABLE IF NOT EXISTS credit_draws (\n idempotency_key TEXT PRIMARY KEY,\n account_id TEXT NOT NULL,\n meter TEXT NOT NULL,\n period TEXT NOT NULL,\n quantity REAL NOT NULL,\n nonce TEXT NOT NULL,\n created_at INTEGER NOT NULL\n)", "CREATE TABLE IF NOT EXISTS ai_endpoints (\n scope TEXT NOT NULL CHECK (scope IN ('account', 'repo')),\n owner_id TEXT NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('provider', 'openai', 'cf-gateway')),\n provider TEXT,\n model TEXT NOT NULL,\n base_url TEXT,\n cf_account_id TEXT,\n cf_gateway_id TEXT,\n key_ciphertext TEXT NOT NULL,\n key_iv TEXT NOT NULL,\n -- 0 for keys copied from account_ai_keys (generic seal); re-sealed to their scope and owner on first use.\n scoped_seal INTEGER NOT NULL DEFAULT 1,\n updated_by TEXT,\n updated_at INTEGER NOT NULL, monthly_token_cap INTEGER,\n PRIMARY KEY (scope, owner_id)\n)", "CREATE TABLE IF NOT EXISTS billing_addons (\n account_id TEXT NOT NULL,\n addon TEXT NOT NULL,\n subscription_id TEXT,\n item_id TEXT,\n status TEXT,\n quantity INTEGER NOT NULL DEFAULT 0,\n -- created time (ms) of the newest subscription event applied, so out-of-order deliveries never regress state.\n event_at INTEGER NOT NULL DEFAULT 0,\n -- When the add-on stopped being active; custom domains are released once the grace period after it passes.\n lapsed_at INTEGER,\n updated_at INTEGER NOT NULL,\n PRIMARY KEY (account_id, addon)\n)", "CREATE INDEX IF NOT EXISTS billing_addons_lapsed ON billing_addons(addon, lapsed_at)", "CREATE INDEX IF NOT EXISTS usage_days_meter_day ON usage_days (meter, day)" ];