Small utilities for common one-off admin tasks. All scripts read
credentials from the project's .env file — never hard-coded — so
you can swap Turso databases or rotate tokens without editing code.
Promote a user to admin (users.is_admin = 1) so they can access
/admin.html.
- Reads
TURSO_DATABASE_URL+TURSO_AUTH_TOKENfrom../.env - Looks up the user by
id(preferred) or phone number - Confirms the user exists and isn't already an admin
- Sends an
UPDATE users SET is_admin = 1 ...to Turso's HTTP API - Verifies the change by re-reading the row
# From the project root - by user id (most reliable):
.\scripts\make-admin.ps1 -UserId 1Or by phone number:
.\scripts\make-admin.ps1 -PhoneNumber "+2348012345678"Or edit $DEFAULT_PHONE at the top of make-admin.ps1 and run with no args:
.\scripts\make-admin.ps1Tip: If a phone-number lookup fails even though the user exists, the stored value almost certainly has an invisible character (CR, NBSP, zero-width space) from however signup wrote it. The script will list nearby/recent users so you can read off the
id, then re-run with-UserId <n>to bypass phone matching entirely.
Open scripts\ in Explorer and double-click make-admin.bat.
It uses whatever phone number is set in $DEFAULT_PHONE inside
make-admin.ps1. To pass a different number or user id, run from cmd:
scripts\make-admin.bat +2348012345678
scripts\make-admin.bat --id 1chmod +x scripts/make-admin.sh
# By phone number:
./scripts/make-admin.sh +2348012345678
# Or by user id (most reliable):
./scripts/make-admin.sh --id 1Requires curl and jq (preinstalled on macOS; apt install jq on
Debian/Ubuntu).
A successful run looks like this:
═══════════════════════════════════════════════════════
ScrowPay — Grant Admin
═══════════════════════════════════════════════════════
Phone number : +2348012345678
Env file : C:\Users\you\Scrowpay\.env
→ Reading .env...
Turso URL : https://my-db.turso.io
→ Looking up user...
Found user:
ID : 1
Name : John Doe
Phone : +2348012345678
is_admin : 0 (before)
→ Setting is_admin = 1...
→ Verifying...
✅ Success! User is now an admin.
| Error | Meaning | Fix |
|---|---|---|
Cannot find .env file |
Wrong working dir | Run from project root, or use -EnvFile <path> |
TURSO_DATABASE_URL is missing or still placeholder |
.env not filled in |
Open .env and put the real values from your Turso dashboard |
No user found with phone_number = ... |
Wrong number, wrong DB, hidden char in stored phone, or you haven't signed up yet | Re-run with -UserId <n> using the id printed in the "recent users" list; or sign up first / fix .env |
401 Unauthorized from Turso |
Token expired or wrong | Generate a fresh token in the Turso dashboard and update .env |
You don't need to touch the script. Just update .env:
TURSO_DATABASE_URL=libsql://new-db-name.turso.io
TURSO_AUTH_TOKEN=eyJ...new-token...Re-run the script and it'll talk to the new database.
Open make-admin.ps1 (or .sh) and edit the DEFAULT_PHONE constant
near the top. That's the only place phone numbers are hard-coded.
The pattern is reusable. To add another operations script:
-
Read
.envforTURSO_DATABASE_URL+TURSO_AUTH_TOKEN(or any other secret you need) -
Convert
libsql://...tohttps://... -
POST to
{HTTPS_URL}/v2/pipelinewith the typed-statement body:{ "requests": [ {"type": "execute", "stmt": {"sql": "...", "args": [...]}}, {"type": "close"} ] } -
Authorization header:
Bearer <TURSO_AUTH_TOKEN>
Ideas for future scripts (not built yet):
reset-user-pin.ps1— wipes a user's PIN so they can resetlist-disputes.ps1— quick CLI view of pending disputes without opening the admin UIseed-test-data.ps1— creates a couple of fake transactions for demo recording
Backdates a transaction's shipped_at timestamp to enable immediate
dispute testing without waiting for the delivery timeline.
The dispute functionality requires transactions to be in In_Transit
state. While there's no hard UI restriction on when you can click the
dispute button, for realistic testing you may want the transaction to
appear as if it was shipped days ago. This script modifies the
shipped_at timestamp so you can test disputes immediately.
-
Open
scripts/test-dispute-helper.jsin your editor -
Update the configuration at the top:
const TRANSACTION_ID = 'TXN-your-transaction-id-here'; const DAYS_AGO = 2; // How many days to backdate const TURSO_DATABASE_URL = 'your-turso-url-here'; const TURSO_AUTH_TOKEN = 'your-turso-token-here';
-
Run the script:
node scripts/test-dispute-helper.js
- Updates the
shipped_attimestamp to X days in the past - Allows you to test dispute functionality immediately
- Useful for development, testing, and demos
If you don't want to use Node.js, you can run this directly in your
browser console while on the dashboard page. See TESTING_DISPUTES.md
in the project root for the full command.
- Node.js 14+ (for fetch API support)
- Turso database credentials (URL and auth token)