Skip to content
39 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Merge Cloudflare's usage over its billing cycle: every page read, included amounts once a cycle, a projection, test-mode charges never money in (billing 0052)1-- Cloudflare's usage bill priced over its billing cycle, and money in only
2-- when it is real. See src/cycle.rs, src/costs.rs and
3-- docs/BILLING_OPERATIONS.md ("The billing cycle").
4
5-- What Cloudflare's line itself said it cost (never its list cost, which
6-- is before the included amounts), what of the quantity is past the
7-- cycle's included amount, and where cost_usd came from: 'cloudflare',
8-- 'list' (the list price past the included amount) or 'none' (no list
9-- price known). Empty for lines that are not billable usage.
10ALTER TABLE cost_lines ADD COLUMN billed_usd REAL NOT NULL DEFAULT 0;
11ALTER TABLE cost_lines ADD COLUMN billable_quantity REAL NOT NULL DEFAULT 0;
12ALTER TABLE cost_lines ADD COLUMN basis TEXT NOT NULL DEFAULT '';
13
14-- When the current billing cycle started, from the subscriptions' read
15-- (current_period_start): the day of the month every cycle starts on.
16ALTER TABLE cf_subscriptions ADD COLUMN cycle_start TEXT;
17
18-- The last read of each source: what came back, to tell from sudo whether
19-- it was all of it and in which units.
20CREATE TABLE IF NOT EXISTS cost_reads (
21 source TEXT PRIMARY KEY,
22 read_at TEXT NOT NULL,
23 since TEXT NOT NULL,
24 until TEXT NOT NULL,
25 rows INTEGER NOT NULL,
26 pages INTEGER NOT NULL,
27 consumed_rows INTEGER NOT NULL,
28 pricing_only_rows INTEGER NOT NULL,
29 costed_rows INTEGER NOT NULL
30);
31
32-- What workspaces were charged while payments were not live (Stripe's
33-- test mode): given away, never money in.
34ALTER TABLE margin_days ADD COLUMN given_unpaid_micros INTEGER NOT NULL DEFAULT 0;
35
36-- The day payments went live: charges before it were not real money.
37-- Empty until the daily run first sees live payments.
38INSERT OR IGNORE INTO cost_settings (key, value, updated_at, updated_by) VALUES
39 ('payments_live_since', '', '2026-10-09T00:00:00Z', 'migration');

This file's history is long; its oldest lines are credited to the oldest commit read.