Last active
September 3, 2024 17:07
-
-
Save zyqxd/2ebf8670566829a235c045e0c50650d9 to your computer and use it in GitHub Desktop.
Coupons SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Delete coupons from staging test merchant --> | |
select coupons.id, coupons.code, request_token | |
from coupons | |
left join coupon_codes on coupon_codes.code = coupons.code | |
left join discounts on discounts.id = coupons.discounts_id | |
where reason = 5 and coupon_codes.merchant_token = 'ML0T5T2PZE4EK'; | |
sq mysql run coupons staging --metacluster coupons-staging-aurora-005 --db coupons_0_staging --cname rw | |
delete d | |
from discounts d | |
left join coupons c on d.id = c.discount_id | |
left join coupon_codes cc on cc.code = c.code | |
where reason = 5 and cc.merchant_token = 'ML0T5T2PZE4EK'; | |
delete cc | |
from coupon_codes cc | |
left join coupons c on cc.code = c.code | |
where reason = 5 and cc.merchant_token = 'ML0T5T2PZE4EK'; | |
delete c | |
from coupons c | |
where reason = 5 and c.request_token like 'DC.ML0T5T2PZE4EK%'; | |
<!-- | |
app-owners@coupons-staging-aurora-use1-005-green coupons_0_staging> delete d | |
-> from discounts d | |
-> left join coupons c on d.id = c.discount_id | |
-> left join coupon_codes cc on cc.code = c.code | |
-> where reason = 5 and cc.merchant_token = 'ML0T5T2PZE4EK'; | |
Query OK, 1239 rows affected (1.19 sec) | |
app-owners@coupons-staging-aurora-use1-005-green coupons_0_staging> delete cc | |
-> from coupon_codes cc | |
-> left join coupons c on cc.code = c.code | |
-> where reason = 5 and cc.merchant_token = 'ML0T5T2PZE4EK'; | |
Query OK, 1230 rows affected (0.50 sec) | |
app-owners@coupons-staging-aurora-use1-005-green coupons_0_staging> delete c | |
-> from coupons c | |
-> where reason = 5 and c.request_token like 'DC.ML0T5T2PZE4EK%'; | |
Query OK, 1238 rows affected (1.54 sec) | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment