-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_reset.sql
More file actions
93 lines (81 loc) · 1.63 KB
/
quick_reset.sql
File metadata and controls
93 lines (81 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# The below is used to reset the destination tables of a migration
# so we can re-run the migration after fixing bugs
SET @current_max_order_id = 50380;
SET @current_max_booking_id = 50382;
SET @current_max_voucher_id = 50892;
SET @current_max_user_id = 4005;
# order meta
delete
from wp_postmeta
where post_id IN (
select ID
from wp_posts
where post_type='shop_order'
and ID > @current_max_order_id
);
# order items meta
delete
from wp_woocommerce_order_itemmeta
where order_item_id IN (
select order_item_id
from wp_woocommerce_order_items
where order_id > @current_max_order_id
);
# order items
delete
from wp_woocommerce_order_items
where order_id > @current_max_order_id;
# order comments
delete
from wp_comments
where comment_post_ID IN (
select ID
from wp_posts
where post_type='shop_order'
and ID > @current_max_order_id
);
# orders themselves
delete
from wp_posts
where post_type='shop_order'
and ID > @current_max_order_id;
# booking meta
delete
from wp_postmeta
where post_id IN (
SELECT ID
from wp_posts
where post_type='wc_booking'
and ID > @current_max_booking_id
);
# bookings
delete
from wp_posts
where post_type='wc_booking'
and ID > @current_max_booking_id;
# voucher meta
delete
from wp_postmeta
where post_id IN (
select ID
from wp_posts
where post_type='woovouchercodes'
and ID > @current_max_voucher_id
);
# vouchers
delete
from wp_posts
where post_type='woovouchercodes'
and ID > @current_max_voucher_id;
# usermeta
delete
from wp_usermeta
where user_id in (
select ID
from wp_users
where id > @current_max_user_id
);
# users
delete
from wp_users
where id > @current_max_user_id;