Files
YHH 69d0944e63 fix(crash-worker): stop recreating the cli_* window-scan indexes (#7266)
#7258 dropped the three desktop indexes that cost the dashboard its window
prune, but missed their cli_ mirrors — and those are worse than a stale
migration: ensureCLITelemetrySchema issues the CREATE INDEX statements on
every cold start, so dropping them in D1 only lasts until the next CLI
request. Production still had all six.

The cli_ tables carry the same primary keys as their desktop counterparts,
so they lose the same way. Remove the CREATE INDEX statements from both the
runtime schema and migrate-client-surface.sql, and extend the drop migration
to cover all six.

The migration is now ordered against a deploy: it must run after a worker
that no longer recreates them.
2026-08-03 12:52:41 +08:00

40 lines
1.2 KiB
SQL

-- Add isolated CLI telemetry tables without changing the existing Desktop
-- tables. This migration is additive and idempotent: it is safe before or
-- after deploying the surface-aware Worker, and safe to rerun.
-- Apply with:
-- wrangler d1 execute reasonix-crash --remote --file=migrate-client-surface.sql
CREATE TABLE IF NOT EXISTS cli_pings (
date TEXT NOT NULL,
install_id TEXT NOT NULL,
version TEXT NOT NULL,
os TEXT NOT NULL,
arch TEXT NOT NULL,
os_version TEXT NOT NULL DEFAULT '',
opens INTEGER NOT NULL DEFAULT 1,
PRIMARY KEY (date, install_id)
);
CREATE TABLE IF NOT EXISTS cli_metrics (
date TEXT NOT NULL,
version TEXT NOT NULL,
os TEXT NOT NULL,
signal TEXT NOT NULL,
bucket TEXT NOT NULL,
count INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (date, version, os, signal, bucket)
);
CREATE TABLE IF NOT EXISTS cli_metric_users (
date TEXT NOT NULL,
signal TEXT NOT NULL,
bucket TEXT NOT NULL,
install_id TEXT NOT NULL,
version TEXT NOT NULL,
os TEXT NOT NULL,
PRIMARY KEY (date, signal, bucket, install_id)
);
-- No secondary indexes here: every primary key above already leads with `date`.
-- migrate-window-index-fix.sql explains what adding one costs.