-- SQL Migration Script: Update Crypto Payment Status Names -- Renames state values in mps_crypto_payment table to match new code constants -- Run this before deploying the updated codebase BEGIN TRANSACTION; -- Update confirmed-overpaid states to confirmed-overpay UPDATE mps_crypto_payment SET status = 'confirmed-overpay' WHERE status = 'confirmed-overpaid'; UPDATE mps_crypto_payment SET status = 'confirmed-overpay-refunded' WHERE status = 'confirmed-overpaid-refunded'; UPDATE mps_crypto_payment SET status = 'confirmed-overpay-refunded-complete' WHERE status = 'confirmed-overpaid-refunded-complete'; -- Update expired-refunded states to latepay-refunded UPDATE mps_crypto_payment SET status = 'latepay-refunded' WHERE status = 'expired-refunded'; UPDATE mps_crypto_payment SET status = 'latepay-refunded-complete' WHERE status = 'expired-refunded-complete'; -- Update any not-refunded states (if they exist) UPDATE mps_crypto_payment SET status = 'confirmed-overpay-not-refunded' WHERE status = 'confirmed-overpaid-not-refunded'; UPDATE mps_crypto_payment SET status = 'latepay-not-refunded' WHERE status = 'expired-not-refunded'; -- Verify the changes SELECT 'Updated status counts:' as info; SELECT status, COUNT(*) as count FROM mps_crypto_payment GROUP BY status ORDER BY status; -- Commit the transaction COMMIT; -- Instructions: -- 1. Backup your database first: cp data/make_post_sell.sqlite data/make_post_sell.sqlite.backup-$(date +%Y%m%d-%H%M%S) -- 2. Run this script: sqlite3 data/make_post_sell.sqlite < fix_crypto_payment_statuses.sql -- 3. Verify results by checking the status counts above