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
41 linesCodeBlameRaw
1-- Before complimentary enrollment opens in sudo, every workspace except
2-- flagon-io is Free: staff then enroll each one deliberately
3-- (`admin_set_complimentary`). Read-only inventory on 2026-10-14 found only
4-- flagon-io off Free, so on production this changes nothing; it makes the
5-- deploy say so rather than trust that nothing changed since.
6--
7-- What makes a workspace not Free here (`plan_kind_for`): comped or custom
8-- terms, the plan given without its price (`team_granted`), membership of
9-- an enterprise. Each reset is written to the staff audit log first. A plan
10-- paid for at Stripe is not touched: a migration cannot cancel it, and a
11-- paying customer is not demoted by a deploy.
12INSERT INTO admin_actions (id, account, action, detail, by, created_at)
13SELECT 'adm_free_' || id, id, 'terms',
14 'Reset to standard terms before complimentary enrollment (migration 0065): was ' || terms_kind ||
15 CASE WHEN discount_percent <> 0 THEN ', ' || discount_percent || '% off' ELSE '' END ||
16 CASE WHEN team_granted <> 0 THEN ', plan given without its price' ELSE '' END,
17 'billing', strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
18 FROM billing_accounts
19 WHERE kind = 'workspace' AND id <> 'ws_flagon-io'
20 AND (terms_kind <> 'standard' OR discount_percent <> 0 OR team_granted <> 0);
21
22UPDATE billing_accounts
23 SET terms_kind = 'standard', discount_percent = 0, terms_until = NULL, team_granted = 0,
24 terms_set_by = 'billing', terms_set_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
25 WHERE kind = 'workspace' AND id <> 'ws_flagon-io'
26 AND (terms_kind <> 'standard' OR discount_percent <> 0 OR team_granted <> 0);
27
28-- A workspace on an enterprise invoice still being made (migration 0063
29-- guards it) stays until that invoice is finished; staff detach it then.
30-- None existed on 2026-10-14.
31INSERT INTO admin_actions (id, account, action, detail, by, created_at)
32SELECT 'adm_free_member_' || workspace, account_id, 'detach',
33 workspace || ' no longer paid for by ' || account_id || ' (migration 0065)',
34 'billing', strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
35 FROM account_members m WHERE workspace <> 'flagon-io'
36 AND NOT EXISTS (SELECT 1 FROM enterprise_invoice_attempts a, json_each(a.payload, '$.lines') l
37 WHERE a.completed = 0 AND json_extract(l.value, '$.workspace') = m.workspace);
38
39DELETE FROM account_members WHERE workspace <> 'flagon-io'
40 AND NOT EXISTS (SELECT 1 FROM enterprise_invoice_attempts a, json_each(a.payload, '$.lines') l
41 WHERE a.completed = 0 AND json_extract(l.value, '$.workspace') = account_members.workspace);