# Reset test data on a master Keysat (StartOS 0.4.0.x) Pre-launch utility. Wipes every business row (products, policies, codes, licenses, invoices, redemptions, machines) so you can iterate cleanly. **Don't run this on a Keysat with real customers** — it will delete their licenses too. Only use on test installs before you've sold anything. ## What's preserved - Issuer keypair (server_keys table) - Webhook subscribers (webhook_endpoints) - BTCPay connection config and tokens (settings — all `btcpay_*` keys) - Web UI password hash (settings) - Operator name (settings) - Audit log (audit_log) The audit log is preserved on purpose — you'll see the wipe transaction recorded in the daemon's logs (not in the audit_log itself, since the wipe doesn't go through the audit path). ## How to run Run these from any machine that has `start-cli` configured (typically the same workstation you used to install the .s9pk): ```sh # 1) Confirm Keysat is installed and find its package id (should be `keysat`). start-cli package list # 2) Stop the daemon so we don't fight in-flight writes. start-cli package stop keysat # 3) Drop into a shell inside the LXC subcontainer. start-cli package attach keysat ``` You're now inside the Keysat container. `sqlite3` is bundled in the runtime image as of v0.1.0:33, so you can run the wipe directly: ```sh # Inside the container: sqlite3 /data/keysat.db <<'SQL' BEGIN; DELETE FROM machines; DELETE FROM discount_redemptions; DELETE FROM licenses; DELETE FROM invoices; DELETE FROM discount_codes; DELETE FROM policies; DELETE FROM products; COMMIT; SQL # Quick sanity check — every row count should be 0. sqlite3 /data/keysat.db "SELECT (SELECT COUNT(*) FROM products) || ' products, ' || (SELECT COUNT(*) FROM policies) || ' policies, ' || (SELECT COUNT(*) FROM licenses) || ' licenses, ' || (SELECT COUNT(*) FROM invoices) || ' invoices, ' || (SELECT COUNT(*) FROM discount_codes) || ' codes';" # Leave the container shell. exit ``` Back on your host: ```sh # 4) Restart the daemon. start-cli package start keysat ``` After the restart: visit `/admin/`, sign in, and you'll see an empty products list. Recreate everything fresh. ## On a pre-:33 daemon The runtime image before v0.1.0:33 didn't ship with `sqlite3`. If you're on an older build and need to wipe before upgrading: install sqlite3 inside the container before the wipe step: ```sh # Only needed on pre-:33 daemons. apt-get update && apt-get install -y sqlite3 ``` Then run the same SQL block. ## Even simpler: the in-app Delete buttons As of v0.1.0:33, Products and Policies have Delete buttons in the admin UI (with refuse-if-referenced safety). For products/policies that have **no licenses tied to them**, click the buttons one by one — no SQL needed. Once a policy has issued any licenses (active OR revoked), the UI delete is refused; that's when you drop to the SQL above.