Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
27 linesCodeBlameRaw
1-- Freeze an invoice's customer and lines before contacting Stripe. Concurrent
2-- callers and retries use the same attempt even when more usage arrives.
3CREATE TABLE invoice_attempts (
4 id TEXT PRIMARY KEY,
5 workspace TEXT NOT NULL UNIQUE,
6 payload TEXT NOT NULL,
7 created_ms INTEGER NOT NULL,
8 invoice_id TEXT
9);
10
11-- Continue bounded replay across ticks instead of repeatedly reading the
12-- newest 1,000 events and starving an older backlog.
13ALTER TABLE stripe_sync ADD COLUMN replay_after TEXT;
14ALTER TABLE stripe_sync ADD COLUMN replay_since INTEGER;
15ALTER TABLE stripe_sync ADD COLUMN replay_until INTEGER;
16ALTER TABLE stripe_sync ADD COLUMN replay_failed INTEGER;
17
18-- Keep the card that funded a trial even if the workspace changes cards.
19ALTER TABLE trial_grants ADD COLUMN fingerprint TEXT;
20UPDATE trial_grants SET fingerprint = (
21 SELECT c.fingerprint FROM card_checks c WHERE c.workspace = trial_grants.workspace
22 AND c.fingerprint IS NOT NULL AND c.workspace = (
23 SELECT MIN(other.workspace) FROM card_checks other JOIN trial_grants g ON g.workspace = other.workspace
24 WHERE other.fingerprint = c.fingerprint
25 )
26);
27CREATE UNIQUE INDEX trial_grants_by_fingerprint ON trial_grants(fingerprint) WHERE fingerprint IS NOT NULL;