If your store runs on a legacy AfterAds (cc.afterads.com on Cloudflare KV), this guide takes you to v2 on Postgres + Drizzle.
#What changes
| — | "v1 | "v2 |
|---|---|---|
| Storage | Cloudflare KV | Supabase Postgres |
| Schema | key/value | Drizzle ORM |
| Auth | API keys only | Better Auth + cookies + tokens |
| Tracking | Sync | Async + queue |
| Studio | Not available | Available |
| Loyalty | Not available | Available |
#Migration steps
- 1
Export from v1.
node scripts/kv-export.mjsdumps the namespace. - 2
Inspect the export. A JSON file with customers + stores + events.
- 3
Sign up on v2. /auth/sign-up.
- 4
Import into v2.
node --env-file=.env.local scripts/kv-import.mjs --dryto validate, then drop--dry. - 5
Verify counts.
/admin/customersand/admin/storesshould match expected.
#Needs reconfiguration
- API keys — v1 keys don't work on v2. Generate new ones.
- Webhooks — endpoint URLs changed. Update in your dashboard.
- Studio access — Studio is brand new. Start at /studio.
#Post-migration verification
| Check | Command | Expected |
|---|---|---|
| Customers count | SELECT COUNT(*) FROM customers | match v1 export |
| Stores linked | SELECT COUNT(*) FROM stores WHERE customer_id IS NOT NULL | ≥ 95% of v1 |
| Events archived | check tracking_events table | ≥ 90% of v1 |