Files
miti99bot/docs/todo.md
tiennm99 f5e03cfff2 docs: add D1 and Cron guides, update module contract across docs
- docs/using-d1.md and docs/using-cron.md for module authors
- architecture, codebase-summary, adding-a-module, code-standards, deployment-guide refreshed
- CLAUDE.md module contract shows optional crons[] and sql in init
- docs/todo.md tracks manual follow-ups (D1 UUID, first deploy, smoke tests)
2026-04-15 13:29:31 +07:00

1.7 KiB

TODO

Manual follow-ups after the D1 + Cron infra rollout (plan: plans/260415-1010-d1-cron-infra/).

Pre-deploy (required before next npm run deploy)

  • Create the D1 database:

    npx wrangler d1 create miti99bot-db
    

    Copy the returned UUID.

  • Replace REPLACE_ME_D1_UUID in wrangler.toml ([[d1_databases]]database_id) with the real UUID.

  • Commit wrangler.toml with the real UUID (the ID is not a secret).

First deploy verification

  • Run npm run db:migrate -- --dry-run — confirm it lists src/modules/trading/migrations/0001_trades.sql as pending.

  • Run npm run deploy — chain is wrangler deploynpm run db:migratenpm run register.

  • Verify in Cloudflare dashboard:

    • D1 database miti99bot-db shows trading_trades + _migrations tables
    • Worker shows a cron trigger 0 17 * * *

Post-deploy smoke tests

  • Send /buy VNM 10 80000 (or whatever the real buy syntax is) via Telegram, then /history — expect 1 row.

  • Manually fire the cron to verify retention:

    npx wrangler dev --test-scheduled
    # in another terminal:
    curl "http://localhost:8787/__scheduled?cron=0+17+*+*+*"
    

    Check logs for trim-trades output.

Nice-to-have (not blocking)

  • End-to-end test of wrangler dev --test-scheduled documented with real output snippet in docs/using-cron.md.

  • Decide on migration rollback story (currently forward-only). Either document "write a new migration to undo" explicitly, or add a down/ convention.

  • Tune trim-trades schedule if 17:00 UTC conflicts with anything — currently chosen as ~00:00 ICT.

  • Consider per-environment D1 (staging vs prod) if a staging bot is added later.