flagon-io/g1t

public

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/services/billing/migrations/0015_sandbox_at_cost.sql

17 lines887 bytesCodeBlame
1-- Sandbox time is charged at cost plus 20% from the first second, like
2-- everything else in the price book. There are no free minutes, so the
3-- monthly count that measured them goes.
4
5-- A change can be to the markup rather than to the cost: what it was.
6ALTER TABLE price_changes ADD COLUMN old_markup_percent INTEGER;
7
8INSERT INTO price_changes (id, meter, old_cost_micros, new_cost_micros, markup_percent, old_markup_percent, reason, created_at)
9SELECT 'prc_sandbox_at_cost', meter, cost_micros, cost_micros, 20, markup_percent,
10 'Sandbox time is now charged at cost plus 20% from the first second',
11 strftime('%Y-%m-%dT%H:%M:%SZ', 'now')
12FROM prices WHERE meter = 'sandbox_second' AND markup_percent <> 20;
13
14UPDATE prices SET markup_percent = 20, updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now')
15WHERE meter = 'sandbox_second';
16
17DROP TABLE IF EXISTS sandbox_months;