readest/apps/readest-app/scripts/db
Huang Xin 64d594380c
chore(scripts): add account inspector and account merge scripts for support (#6121)
Tooling for "please merge my two accounts" tickets, both under
apps/readest-app/scripts/db and run with
`node --env-file=.env --env-file=.env.local`.

inspect-accounts.mjs is read-only: it resolves users by email through the
GoTrue admin API and reports identities, per-table row counts, the plans
row, payments, recent book titles for ownership verification, and the
files rows checked against the objects actually present in R2, plus the
book/file overlap between accounts.

merge-accounts.mjs moves one account's cloud data into another account of
the same person: server-side R2 CopyObject with a HEAD size check,
re-pointing books / book_configs / book_notes / stat_* / replicas / files
rows with the file_key prefix rewritten, newer-updated_at-wins on
primary-key collisions, updated_at stamped on the tables whose sync pull
keys on it, then plans.storage_usage_bytes recomputed on both users.
Files rows with no object behind them (abandoned upload reservations) are
left behind. Dry run by default; --apply writes.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-07 16:56:55 +02:00
..
inspect-accounts.mjs chore(scripts): add account inspector and account merge scripts for support (#6121) 2026-09-07 16:56:55 +02:00
merge-accounts.mjs chore(scripts): add account inspector and account merge scripts for support (#6121) 2026-09-07 16:56:55 +02:00
verify-migration-020.sh fix(stats): survive PostgREST's row cap when building archive segments (#5844) 2026-08-24 15:07:01 +02:00