| 1 | -- Apply: wrangler d1 execute reasonix-crash --remote --file=migrate-drop-metric-users.sql |
| 2 | -- |
| 3 | -- Retires per-install metric detail. The 30-day COUNT(DISTINCT install_id) it |
| 4 | -- fed was the database's entire read bill: the primary key leads with `date`, |
| 5 | -- so the rollup's `date >= ... AND signal = ?` could only prune the window and |
| 6 | -- scanned all ~28M rows once per signal, eight signals an hour — ~5.4B rows |
| 7 | -- read a day for one dashboard module. The aggregate `metrics` tables keep the |
| 8 | -- same signals as event counts at ~180k rows total. |
| 9 | -- |
| 10 | -- Deploy the worker first: it stops writing these tables and stops creating |
| 11 | -- them at runtime, so a DROP before that just gets rebuilt on the next request. |
| 12 | DROP TABLE IF EXISTS metric_user_rollup; |
| 13 | DROP TABLE IF EXISTS metric_user_rollup_state; |
| 14 | DROP TABLE IF EXISTS metric_users; |
| 15 | DROP TABLE IF EXISTS cli_metric_users; |
| 16 |