-- +goose Up -- Telegram Stars as a second payment method. Every purchase and every -- ledger entry says how it was paid; everything before this was Lightning. ALTER TABLE purchases ADD COLUMN payment_method TEXT NOT NULL DEFAULT 'lightning'; -- What a Stars purchase cost in Stars. amount_sats keeps the sats value of -- what it bought (the credit pack, or the pass price) for the wallet. ALTER TABLE purchases ADD COLUMN stars_amount BIGINT NOT NULL DEFAULT 0; -- Telegram's identifier of a Stars payment. Unique, so the same payment -- event can never settle twice. ALTER TABLE purchases ADD COLUMN tg_charge_id TEXT NOT NULL DEFAULT ''; ALTER TABLE purchases ADD COLUMN refunded_at BIGINT NOT NULL DEFAULT 0; CREATE UNIQUE INDEX purchases_charge_idx ON purchases (tg_charge_id) WHERE tg_charge_id <> ''; CREATE INDEX purchases_method_idx ON purchases (payment_method, status); ALTER TABLE ledger ADD COLUMN payment_method TEXT NOT NULL DEFAULT 'lightning'; -- +goose Down ALTER TABLE ledger DROP COLUMN payment_method; DROP INDEX purchases_method_idx; DROP INDEX purchases_charge_idx; ALTER TABLE purchases DROP COLUMN refunded_at; ALTER TABLE purchases DROP COLUMN tg_charge_id; ALTER TABLE purchases DROP COLUMN stars_amount; ALTER TABLE purchases DROP COLUMN payment_method;