Overview
Verifieddit uses Cloudflare D1 (SQLite-compatible) for persistent storage. There are separate production and testing databases.
Databases
| Name | Environment | Binding |
|---|---|---|
verifieddit-badges | Production | DB |
verifieddit-badges-testing | Testing | DB |
Prerequisites
- Wrangler CLI:
npx wrangler - Cloudflare account authenticated:
npx wrangler login
Common Operations
List All D1 Databases
| |
Query a Database
| |
Create a Table
| |
Insert Data
| |
Update Data
| |
Delete Data
| |
Migrations
Running a Migration File
| |
Migration Best Practices
- Always test migrations on the testing database first
- Use
IF NOT EXISTS/IF EXISTSfor idempotent migrations - Keep migration files numbered sequentially
- SQLite does not support
DROP COLUMN– you must recreate the table
Query via Cloudflare API
For programmatic access outside of wrangler:
| |
Backup and Export
Export Table Data
| |
Export Schema
| |
Schema Reference
badges
| |
badge_images
| |
users
| |
Troubleshooting
- “Table not found”: Run the migration to create the table. Check you’re querying the correct database (production vs testing).
- “Database locked”: D1 has concurrent write limitations. Retry the operation.
- Data mismatch between environments: Production and testing databases are independent. Migrations must be run on both.
- JSON output truncated: Large result sets may be truncated. Use
LIMITandOFFSETfor pagination.