Files

15 lines
769 B
SQL
Raw Permalink Normal View History

-- Paid analyses are counted per kind instead of generic credits: a
-- detailed natal analysis uses one 'natal' unit, a synastry analysis one
-- 'synastry' unit. Units are bought in packages (or granted by an admin).
-- The free monthly credits are gone: the free part is the short summary.
DELETE FROM credit_ledger WHERE reason = 'monthly_grant';
ALTER TABLE credit_ledger ADD COLUMN unit text NOT NULL DEFAULT 'natal' CHECK (unit IN ('natal', 'synastry'));
ALTER TABLE credit_ledger ALTER COLUMN unit DROP DEFAULT;
DROP INDEX credit_ledger_user_idx;
CREATE INDEX credit_ledger_user_idx ON credit_ledger (user_id, unit, created_at DESC);
COMMENT ON COLUMN analyses.credits_charged IS 'Units of the analysis kind spent on it (0 or 1; 0 for summaries and copies)';