⚡ SONAN TECH

Location Launchpad Docs

Cloudflare D1 Guide← Docs Home

Cloudflare D1 Guide

How to create, manage, migrate, seed, inspect, and back up the D1 database.

Create the Database

wrangler d1 create sonan-location-launchpad

Copy the database_id and add it to wrangler.toml.

Run Migrations

# Local
wrangler d1 execute sonan-location-launchpad --file=db/migrations/001_schema.sql

# Remote (production)
wrangler d1 execute sonan-location-launchpad --remote --file=db/migrations/001_schema.sql

Seed Data

wrangler d1 execute sonan-location-launchpad --remote --file=db/seed/seed.sql

Inspect Records

# List all locations
wrangler d1 execute sonan-location-launchpad --remote --command="SELECT * FROM locations"

# Count tasks per location
wrangler d1 execute sonan-location-launchpad --remote --command="SELECT location_id, COUNT(*) as tasks FROM tasks GROUP BY location_id"

# View overdue tasks
wrangler d1 execute sonan-location-launchpad --remote --command="SELECT title, due_date FROM tasks WHERE due_date < date('now') AND status != 'Done'"

Run Any SQL

wrangler d1 execute sonan-location-launchpad --remote --command="YOUR SQL HERE"

Export / Backup

wrangler d1 export sonan-location-launchpad --remote --output backup.sql

This creates a backup.sql file with all schema and data. Store this in a secure location (e.g., Google Drive, encrypted S3).

D1 Limits (Free Tier)

ResourceFree Limit
Storage5 GB
Reads/day25 million rows
Writes/day50,000 rows
Databases10
The Location Launchpad will use a tiny fraction of these limits even with dozens of locations.