diff --git a/address_util/delete-orders-before-2026-02-10.sql b/address_util/delete-orders-before-2026-02-10.sql new file mode 100644 index 0000000..8711cc1 --- /dev/null +++ b/address_util/delete-orders-before-2026-02-10.sql @@ -0,0 +1,83 @@ +-- ============================================================ +-- delete-orders-before-2026-02-10.sql +-- +-- DESTRUCTIVE. Deletes every order created before 2026-02-10 (midnight, +-- exclusive -- anything on/after 2026-02-10 00:00 is kept) and the rows that +-- hang off those orders. +-- +-- Cutoff: `created_at < '2026-02-10'` compares correctly for the timestamp +-- shapes the app writes ('2026-02-09T23:00:00.000Z' and '2026-02-09 23:00:00'). +-- +-- Schema: this targets the post-0006 database (applied to the remote now). +-- 0006 removed online payments, so `payments`, `refunds` and `payment_info` no +-- longer exist and `orders.payment_info_id` is gone -- none are referenced here. +-- (The same statements also run on a pre-0006 copy; they just leave the dropped +-- payment tables alone.) +-- +-- Per order it: +-- 1. detaches coupon_usage / complaints / user_incidents (rows kept, order +-- references set to NULL, so coupon limits and complaint history survive) +-- 2. deletes its order_items and order_status rows +-- 3. deletes the order +-- +-- Post-0006 orders whose items were archived into `orders.items_json` have no +-- `order_items` rows, so only the order/status row is removed for them. +-- +-- Counts from the local dump at time of writing (pre-0006 copy): +-- 110 of 2548 orders (oldest 2025-12-24), 194 order_items, 110 order_status, +-- 23 coupon_usage detached, 1 complaint detached, 0 user_incidents. +-- Counts will differ on the target database. +-- +-- Apply from apps/backend: +-- wrangler d1 execute freshyo-backend-dev --file=../../address_util/delete-orders-before-2026-02-10.sql --config wrangler.dev.toml --remote +-- +-- Dry run (counts only): +-- SELECT COUNT(*) FROM orders WHERE created_at < '2026-02-10'; +-- ============================================================ + +-- 1. Preserve cross-cutting history; drop only the order references. +UPDATE coupon_usage +SET order_id = NULL, + order_item_id = NULL +WHERE order_id IN (SELECT id FROM orders WHERE created_at < '2026-02-10') + OR order_item_id IN ( + SELECT oi.id FROM order_items oi + JOIN orders o ON o.id = oi.order_id + WHERE o.created_at < '2026-02-10' + ); + +UPDATE complaints +SET order_id = NULL +WHERE order_id IN (SELECT id FROM orders WHERE created_at < '2026-02-10'); + +UPDATE user_incidents +SET order_id = NULL +WHERE order_id IN (SELECT id FROM orders WHERE created_at < '2026-02-10'); + +-- 2. Delete the order-owned item/status rows. +DELETE FROM order_items +WHERE order_id IN (SELECT id FROM orders WHERE created_at < '2026-02-10'); + +DELETE FROM order_status +WHERE order_id IN (SELECT id FROM orders WHERE created_at < '2026-02-10'); + +-- 3. Delete the orders themselves. +DELETE FROM orders +WHERE created_at < '2026-02-10'; + +-- Verification (run after applying): +-- SELECT COUNT(*) FROM orders WHERE created_at < '2026-02-10'; -- expect 0 +-- SELECT COUNT(*) FROM order_items +-- WHERE order_id NOT IN (SELECT id FROM orders); -- expect 0 +-- SELECT COUNT(*) FROM order_status +-- WHERE order_id NOT IN (SELECT id FROM orders); -- expect 0 +-- SELECT COUNT(*) FROM coupon_usage +-- WHERE order_id IS NOT NULL +-- AND order_id NOT IN (SELECT id FROM orders); -- expect 0 +-- SELECT COUNT(*) FROM complaints +-- WHERE order_id IS NOT NULL +-- AND order_id NOT IN (SELECT id FROM orders); -- expect 0 +-- SELECT COUNT(*) FROM user_incidents +-- WHERE order_id IS NOT NULL +-- AND order_id NOT IN (SELECT id FROM orders); -- expect 0 +-- PRAGMA foreign_key_check; -- expect no rows diff --git a/address_util/run-commands.txt b/address_util/run-commands.txt index ed23dcd..7623e77 100644 --- a/address_util/run-commands.txt +++ b/address_util/run-commands.txt @@ -7,16 +7,16 @@ cd apps/backend # 1. Admin coords (idempotent) -wrangler d1 execute freshyo-backend-dev --file=../../address_util/backfill-admin-coords.sql --config wrangler.dev.toml --remote +wrangler d1 execute freshyo-dev --file=../../address_util/backfill-admin-coords.sql --config wrangler.prod.toml --remote # 2. Computed bounds for the 466 non-vague addresses -wrangler d1 execute freshyo-backend-dev --file=../../address_util/computed-bounds-466.sql --config wrangler.dev.toml --remote +wrangler d1 execute freshyo-dev --file=../../address_util/computed-bounds-466.sql --config wrangler.prod.toml --remote # 3. Manual bounds + coords for the 416 vague addresses -wrangler d1 execute freshyo-backend-dev --file=../../address_util/address-bound-coord-updates.sql --config wrangler.dev.toml --remote +wrangler d1 execute freshyo-dev --file=../../address_util/address-bound-coord-updates.sql --config wrangler.prod.toml --remote # 4. Delete the 23 selected addresses (run last) -wrangler d1 execute freshyo-backend-dev --file=../../address_util/delete-outside-bound-addresses.sql --config wrangler.dev.toml --remote +wrangler d1 execute freshyo-dev --file=../../address_util/delete-outside-bound-addresses.sql --config wrangler.prod.toml --remote # Optional verification wrangler d1 execute freshyo-backend-dev --config wrangler.dev.toml --command="SELECT bound_id, COUNT(*) AS n FROM addresses GROUP BY bound_id ORDER BY bound_id" --remote diff --git a/apps/backend/API-TEST-CASES.md b/apps/backend/API-TEST-CASES.md index 3e9a7a2..f3271dc 100644 --- a/apps/backend/API-TEST-CASES.md +++ b/apps/backend/API-TEST-CASES.md @@ -593,7 +593,7 @@ Covered comprehensively by section 4 (CACHE-01..24); add procedure-level cases: | ID | Type | Case | Assert | | --- | --- | --- | --- | -| COMMON-74 | edge | missing `boundId` input | BAD_REQUEST | +| COMMON-74 | edge | missing `boundId` input (legacy no-arg call) | falls back to bound 1 / region 1 | | COMMON-75 | edge | boundId 0/negative/float | BAD_REQUEST | | COMMON-76 | edge | no token | succeeds | | COMMON-77 | edge | response shape flat (no nesting) | all keys at root | @@ -1945,7 +1945,8 @@ These are intentionally written as “current” cases until the underlying defe 14. Cache rebuilds are non-atomic and eventual; every cache test must poll, never sleep once. 15. `cacheVersion`/`slotsVersionNum`/`availabilityVersionNum` are old names; use `products_version_num`/`slots_version_num`/`availability_version_num`. -16. `common.essentialConsts` requires `boundId`; the old suite’s no-arg call no longer compiles. +16. `common.essentialConsts` accepts an optional `boundId`; a missing input is a temporary + backwards-compatibility path that falls back to bound 1 (region 1). --- diff --git a/apps/backend/dumps/latest.sql b/apps/backend/dumps/latest.sql index 4b3d138..d62131c 100644 --- a/apps/backend/dumps/latest.sql +++ b/apps/backend/dumps/latest.sql @@ -2914,7 +2914,7 @@ INSERT INTO "key_val_store" ("key","value") VALUES('deliveryCharge','15'); INSERT INTO "key_val_store" ("key","value") VALUES('flashDeliveryCharge','39.0'); INSERT INTO "key_val_store" ("key","value") VALUES('flashFreeDeliveryThreshold','399'); INSERT INTO "key_val_store" ("key","value") VALUES('freeDeliveryThreshold','249'); -INSERT INTO "key_val_store" ("key","value") VALUES('isFlashDeliveryEnabled','true'); +INSERT INTO "key_val_store" ("key","value") VALUES('isFlashDeliveryEnabled','false'); INSERT INTO "key_val_store" ("key","value") VALUES('minRegularOrderValue','249'); INSERT INTO "key_val_store" ("key","value") VALUES('playStoreUrl','https://info.freshyo.in/qr-based-download'); INSERT INTO "key_val_store" ("key","value") VALUES('popularItems','40,109,9,75,98,6,24,59'); @@ -2949,7 +2949,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(24,'ExponentPushToken[B2zWnHNaumIgbeFFKO-15D]','2026-02-09T19:53:37.594Z',113,'2026-02-10T07:43:48.632Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(25,'ExponentPushToken[wIhrdlAmwj0Eytvz3W3TTZ]','2026-02-10T11:09:24.848Z',127,'2026-04-18T06:53:49.329Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(26,'ExponentPushToken[hFUlPFOKMdAUgtDP7EtSzM]','2026-02-10T11:33:43.821Z',3,'2026-02-24T11:16:46.799Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(27,'ExponentPushToken[NymZTEED3G7YCyDg7ihgBA]','2026-02-11T03:16:04.540Z',2,'2026-10-25T03:19:14.196Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(27,'ExponentPushToken[NymZTEED3G7YCyDg7ihgBA]','2026-02-11T03:16:04.540Z',2,'2026-10-25T12:56:35.446Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(28,'ExponentPushToken[ARCT4KD7CJ_pFF_GkywepP]','2026-02-11T11:34:32.238Z',115,'2026-10-17T09:44:00.809Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(29,'ExponentPushToken[NN4v16BFslBX8ryVXDwQIg]','2026-02-12T08:46:42.421Z',128,'2026-02-17T19:04:12.936Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(30,'ExponentPushToken[qbteKBC1wbLMCe1ltpul7u]','2026-02-12T13:28:00.376Z',129,'2026-02-12T13:28:00.375Z'); @@ -3270,7 +3270,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(377,'ExponentPushToken[OUHHZDAcdmpUwkHVo6sX1T]','2026-05-11 09:43:23',437,'2026-08-01T15:49:31.050Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(378,'ExponentPushToken[6GIZ9PGsRkWk9Vd4XtVoP0]','2026-05-12 04:54:49',438,'2026-05-12T05:41:19.561Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(379,'ExponentPushToken[VY1lpUFK2Fw6V6aJ5LokIt]','2026-05-12 06:03:32',439,'2026-06-10T04:33:08.668Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(380,'ExponentPushToken[GA8vDtGZGSLyXTIw8p73Z2]','2026-05-12 07:14:36',440,'2026-10-20T07:31:50.339Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(380,'ExponentPushToken[GA8vDtGZGSLyXTIw8p73Z2]','2026-05-12 07:14:36',440,'2026-10-25T11:11:07.903Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(381,'ExponentPushToken[nTI6kIOJyQjAEsl9kLdguv]','2026-05-12 08:40:29',441,'2026-05-15T17:29:56.071Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(382,'ExponentPushToken[BwD4IWC1zCruWA2ZZcRZ9n]','2026-05-13 02:12:47',444,'2026-10-13T05:27:00.418Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(383,'ExponentPushToken[89CRhTI7hACC4Z7qHwx0Ol]','2026-05-13 04:22:12',96,'2026-05-13T04:22:12.371Z'); @@ -3370,7 +3370,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(477,'ExponentPushToken[xW60lBF5T8QZhcukLKWiLT]','2026-06-13 06:50:53',539,'2026-06-13T06:50:53.542Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(478,'ExponentPushToken[OcXxPHN4S6jSOcfUst66iz]','2026-06-13 13:05:48',541,'2026-06-13T13:05:47.880Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(479,'ExponentPushToken[MDMAekEhhWndpo2uBAD9Aa]','2026-06-14 08:02:34',542,'2026-06-14T08:02:34.279Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(480,'ExponentPushToken[-mWZEMNqDOXZj9ESRGhRuA]','2026-06-15 12:02:30',414,'2026-10-21T08:49:02.351Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(480,'ExponentPushToken[-mWZEMNqDOXZj9ESRGhRuA]','2026-06-15 12:02:30',414,'2026-10-25T09:29:14.781Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(481,'ExponentPushToken[C36i1zA_O5lmgPSe0H6GCS]','2026-06-17 06:17:53',544,'2026-09-06T15:30:50.969Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(482,'ExponentPushToken[Kl7RrWOFizANCgLbHBZDTO]','2026-06-17 11:56:17',545,'2026-06-21T08:01:57.256Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(483,'ExponentPushToken[3R26bUHCHaUtIoOnHLVbTX]','2026-06-17 13:50:26',121,'2026-06-17T13:53:22.079Z'); @@ -3568,7 +3568,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(675,'ExponentPushToken[y9yrBKHPbgGnun6nnc5i1B]','2026-08-14 13:27:22',742,'2026-08-14T15:44:49.270Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(676,'ExponentPushToken[oQElZlIz-BmfNNc5K5d064]','2026-08-15 05:33:31',744,'2026-08-16T05:24:08.729Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(677,'ExponentPushToken[6Xwr72LnxNHJytsy7Cs5at]','2026-08-15 06:00:14',745,'2026-09-25T05:46:59.699Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(678,'ExponentPushToken[4I1Ye1NW8ORECiWtNz3qOn]','2026-08-15 08:37:53',747,'2026-10-18T07:18:12.838Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(678,'ExponentPushToken[4I1Ye1NW8ORECiWtNz3qOn]','2026-08-15 08:37:53',747,'2026-10-25T07:20:48.182Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(679,'ExponentPushToken[yuHQyvGAG_dBwAWTTQmKUA]','2026-08-15 11:54:37',282,'2026-08-15T11:54:37.722Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(680,'ExponentPushToken[MgtQoXCibg773i-imr3I8M]','2026-08-15 12:48:50',749,'2026-10-15T01:34:29.548Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(681,'ExponentPushToken[lcPixFOTlC_8ut1jmkvGcf]','2026-08-16 03:48:16',750,'2026-10-25T04:04:16.469Z'); @@ -3975,7 +3975,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1085,'ExponentPushToken[WNFDt7O_XwLLi9o4Kzkxh1]','2026-09-16 17:05:05',1141,'2026-09-16T17:05:05.695Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1086,'ExponentPushToken[iy4keVDskW3UeguQ98IC18]','2026-09-16 18:28:01',1185,'2026-10-24T05:17:12.615Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1087,'ExponentPushToken[ztKEwrJShQuweUycnFsIEf]','2026-09-17 01:31:58',1186,'2026-09-17T01:57:18.495Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1088,'ExponentPushToken[sAd4YtJL7eNiyZYFLQ9RIS]','2026-09-17 03:54:31',1187,'2026-10-23T15:31:06.766Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1088,'ExponentPushToken[sAd4YtJL7eNiyZYFLQ9RIS]','2026-09-17 03:54:31',1187,'2026-10-25T09:01:57.753Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1089,'ExponentPushToken[LfAPs1IUnZSrW11L2P6Ljq]','2026-09-17 07:32:13',1188,'2026-10-21T06:43:54.928Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1090,'ExponentPushToken[FRvK5qOdOnOM3J_ewfgEVy]','2026-09-17 07:55:21',1078,'2026-10-24T14:25:40.537Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1091,'ExponentPushToken[QqPqRuL-HlsUOJkxoPiPCX]','2026-09-17 09:16:46',1011,'2026-09-17T11:40:10.585Z'); @@ -4027,7 +4027,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1137,'ExponentPushToken[4nko9iNLxcniPOe9_HVD_L]','2026-09-23 19:46:36',1240,'2026-10-18T11:54:25.649Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1138,'ExponentPushToken[ROzLrXEV42b3SoLOlH1pTa]','2026-09-24 07:22:00',1242,'2026-09-24T07:22:00.760Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1139,'ExponentPushToken[m_CWoiJlWlpI5RBLEJLmyE]','2026-09-24 08:35:22',350,'2026-10-10T08:47:26.932Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1140,'ExponentPushToken[wF1z8fDeSMGHlPRBbETioe]','2026-09-24 09:29:15',1243,'2026-10-21T17:55:33.656Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1140,'ExponentPushToken[wF1z8fDeSMGHlPRBbETioe]','2026-09-24 09:29:15',1243,'2026-10-25T08:49:18.058Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1141,'ExponentPushToken[5CzesiC5I-3Qs5F0jCYAnS]','2026-09-24 12:43:25',776,'2026-09-24T12:43:25.667Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1142,'ExponentPushToken[CGgtzRDOVD5HEIxnDjnWzt]','2026-09-24 13:12:45',1245,'2026-09-24T13:19:02.736Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1143,'ExponentPushToken[8RCScPBEYU-s_L8TiYNsOE]','2026-09-24 13:55:59',1246,'2026-10-08T02:37:33.996Z'); @@ -6683,9 +6683,9 @@ INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged" INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2702,'2026-10-25 04:10:05',1085,2708,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2703,'2026-10-25 04:11:39',493,2709,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2704,'2026-10-25 04:28:34',688,2710,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); -INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2705,'2026-10-25 04:33:49',82,2711,0,0,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); -INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2706,'2026-10-25 05:46:20',523,2712,0,0,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); -INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2707,'2026-10-25 06:24:32',1351,2713,0,0,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2705,'2026-10-25 04:33:49',82,2711,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2706,'2026-10-25 05:46:20',523,2712,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2707,'2026-10-25 06:24:32',1351,2713,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); CREATE TABLE IF NOT EXISTS "orders" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "address_id" INTEGER NOT NULL, "slot_id" INTEGER, "total_amount" REAL NOT NULL, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_cod" INTEGER NOT NULL DEFAULT false, "is_online_payment" INTEGER NOT NULL DEFAULT false, "payment_info_id" INTEGER, "readable_id" INTEGER NOT NULL, "admin_notes" TEXT, "user_notes" TEXT, "delivery_charge" REAL NOT NULL DEFAULT '0', "order_group_id" TEXT, "order_group_proportion" REAL, "is_flash_delivery" INTEGER NOT NULL DEFAULT false, `delivered_at` text); INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(105,22,31,9,7700,'2025-12-24T02:50:33.284Z',1,0,NULL,147,NULL,NULL,0,NULL,NULL,0,NULL); INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(106,15,24,8,92,'2025-12-24T10:32:01.957Z',1,0,NULL,149,NULL,NULL,20,NULL,NULL,0,NULL); @@ -11409,7 +11409,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1642,'ExponentPushToken[-KFqDsP-HC2Q-0s6Fc-Ipy]','2026-09-11 16:03:37','2026-09-15T14:32:12.599Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1645,'ExponentPushToken[dg-_wDCEwufWZx4CxFHRTG]','2026-09-11 16:05:59','2026-10-06T09:28:09.270Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1648,'ExponentPushToken[aS9CGuNtZQ6afSDXwTdbaU]','2026-09-11 16:07:09','2026-09-30T15:24:44.752Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1649,'ExponentPushToken[7K3X1gK_zFoLS7Wm3p9Hhl]','2026-09-11 16:07:41','2026-10-19T01:24:21.869Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1649,'ExponentPushToken[7K3X1gK_zFoLS7Wm3p9Hhl]','2026-09-11 16:07:41','2026-10-25T09:04:30.128Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1651,'ExponentPushToken[0wZ4INHRS_gGL4hTsgJ7C-]','2026-09-11 16:08:52','2026-09-11T16:08:52.838Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1652,'ExponentPushToken[RpD1OGLWPTJ36Lb_KCAlFa]','2026-09-11 16:08:59','2026-09-13T18:31:08.061Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1653,'ExponentPushToken[02oH-mMJZFldfXVfqxOPE6]','2026-09-11 16:11:23','2026-09-14T06:17:42.788Z'); @@ -11954,7 +11954,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2353,'ExponentPushToken[aITcTXM3kUTvLkCku51RVY]','2026-10-13 01:09:38','2026-10-13T01:09:38.688Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2354,'ExponentPushToken[oVlx4lOzXHflUavRWxGcH4]','2026-10-14 01:27:54','2026-10-14T01:27:54.416Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2356,'ExponentPushToken[fx_Z4hJDBIhccI36Sd-7ZV]','2026-10-14 05:48:40','2026-10-20T12:35:06.658Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2357,'ExponentPushToken[uN7Q2SJXcDEsKhYeb2PeVF]','2026-10-14 11:33:41','2026-10-24T07:24:10.154Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2357,'ExponentPushToken[uN7Q2SJXcDEsKhYeb2PeVF]','2026-10-14 11:33:41','2026-10-25T07:30:22.335Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2358,'ExponentPushToken[T6VyuGAkKtOnyMGSwa1XuM]','2026-10-14 11:55:18','2026-10-23T06:21:10.776Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2359,'ExponentPushToken[d75jOiFseYEe8N39v2XSV-]','2026-10-14 13:44:19','2026-10-14T13:44:19.755Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2360,'ExponentPushToken[lig2boHMSviJFdVsR3j86H]','2026-10-14 16:28:32','2026-10-14T16:28:32.826Z'); @@ -12003,6 +12003,8 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2410,'ExponentPushToken[hWm-eGPbpHPjZaZ57hgsmC]','2026-10-24 13:32:58','2026-10-24T15:49:57.067Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2411,'ExponentPushToken[Kd6H6PA84cbHP1ixcjt8JU]','2026-10-24 19:15:04','2026-10-24T19:25:57.389Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2412,'ExponentPushToken[d6lbVHISTzXujRK8QTQUAY]','2026-10-25 01:18:56','2026-10-25T01:18:56.039Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2413,'ExponentPushToken[pfqXpQBHFC-S20jwotBFnN]','2026-10-25 06:39:13','2026-10-25T06:39:13.035Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2414,'ExponentPushToken[q-Lmz6DuN8mvoHTG1u9odS]','2026-10-25 07:42:50','2026-10-25T07:42:50.356Z'); CREATE TABLE IF NOT EXISTS "upload_url_status" ("id" INTEGER PRIMARY KEY, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "key" TEXT NOT NULL, "status" TEXT NOT NULL DEFAULT 'pending'); INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(35,'2025-12-07T08:58:13.136Z','review-images/1765097892914.jpg','pending'); INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(36,'2025-12-07T08:58:13.347Z','review-images/1765097893129.png','pending'); @@ -23279,12 +23281,12 @@ INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discount INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9125,2708,98,'1','449','449',1,0,NULL); INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9126,2709,14,'1','449','449',1,0,NULL); INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9127,2710,137,'1','305','305',1,0,NULL); -INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9128,2711,10,'2','299','299',0,0,NULL); -INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9129,2712,40,'2','153','153',0,0,NULL); -INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9130,2713,33,'2','15.0','15.0',0,0,NULL); -INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9131,2713,71,'1','15.0','15.0',0,0,NULL); -INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9132,2713,6,'1','109.0','109.0',0,0,NULL); -INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9133,2713,31,'2','16','16',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9128,2711,10,'2','299','299',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9129,2712,40,'2','153','153',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9130,2713,33,'2','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9131,2713,71,'1','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9132,2713,6,'1','109.0','109.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(9133,2713,31,'2','16','16',1,0,NULL); CREATE TABLE IF NOT EXISTS "special_deals" ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `sku_id` integer NOT NULL, @@ -23724,7 +23726,7 @@ CREATE TABLE `staff_notif_creds` ( ); INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(1,'ExponentPushToken[HyU1kPNunSJaasQweODhvH]','2026-10-02 10:49:17',6,'2026-10-04T07:19:37.555Z'); INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(2,'ExponentPushToken[QydqxGMsUfzHuiqxel0nA9]','2026-10-02 10:49:27',4,'2026-10-20T07:30:34.519Z'); -INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(3,'ExponentPushToken[bqqW02IeK4XcC4iuzpkQIG]','2026-10-05 01:28:42',4,'2026-10-25T05:50:41.894Z'); +INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(3,'ExponentPushToken[bqqW02IeK4XcC4iuzpkQIG]','2026-10-05 01:28:42',4,'2026-10-25T13:27:06.541Z'); DELETE FROM sqlite_sequence; INSERT INTO "sqlite_sequence" ("name","seq") VALUES('product_skus',150); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('sku_features',183); diff --git a/apps/backend/src/trpc/apis/common-apis/common-trpc-index.ts b/apps/backend/src/trpc/apis/common-apis/common-trpc-index.ts index d61c711..4a689aa 100644 --- a/apps/backend/src/trpc/apis/common-apis/common-trpc-index.ts +++ b/apps/backend/src/trpc/apis/common-apis/common-trpc-index.ts @@ -262,9 +262,14 @@ export const commonApiRouter = router({ }), essentialConsts: publicProcedure - .input(z.object({ boundId: z.number().int().positive() })) + // TEMPORARY (backwards compatibility): older app builds call this procedure + // with no input. Every field is optional now; a missing bound falls back to + // bound 1 (region 1, Mahabubnagar). Remove this block once no shipped build + // relies on it. + .input(z.object({ boundId: z.number().int().positive().optional() }).optional()) .query(async ({ ctx, input }) => { - console.log({ boundId: input.boundId }) + const boundId = input?.boundId ?? 1 + console.log({ boundId }) const requestUrl = ctx.req.url const host = new URL(requestUrl).host const updateNotice = `