Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save remcotolsma/175e7423a2fc60248997d03000251fe8 to your computer and use it in GitHub Desktop.
Save remcotolsma/175e7423a2fc60248997d03000251fe8 to your computer and use it in GitHub Desktop.
Pronamic Pay database queries to change the last subscription phase amount.
SELECT
post.ID AS post_id,
post.post_date,
post.post_content->>'$.source.key' AS source_key,
-- The '200' value represents the new amount.
JSON_REPLACE( post.post_content, '$.phases[last].amount.value', '200' ) AS post_content
FROM
wp_posts AS post
WHERE
post.post_type = 'pronamic_pay_subscr'
AND
post.post_status = 'subscr_active'
AND
JSON_VALID( post.post_content )
AND
post.post_content->>'$.source.key' = 'gravityformsideal'
AND
-- The '100' value represents the current amount.
post.post_content->>'$.phases[last].amount.value' = '100'
;
UPDATE
wp_posts AS post
SET
-- The '200' value represents the new amount.
post.post_content = JSON_REPLACE( post.post_content, '$.phases[last].amount.value', '200' )
WHERE
post.post_type = 'pronamic_pay_subscr'
AND
post.post_status = 'subscr_active'
AND
JSON_VALID( post.post_content )
AND
post.post_content->>'$.source.key' = 'gravityformsideal'
AND
-- The '100' value represents the current amount.
post.post_content->>'$.phases[last].amount.value' = '100'
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment