472 lines
27 KiB
Text
472 lines
27 KiB
Text
=== Session change log ===
|
|
Session started: 2026-09-02
|
|
Rule: Before changing any file that is not a .md or .txt file, write the current timestamp followed by the exact diff here first, then make the change.
|
|
|
|
(no file changes made yet in this session)
|
|
|
|
[2026-09-02 20:34:48] DELETE dead files per DEAD_CODE_REPORT.md §1 (28 files):
|
|
|
|
Removed in packages/db_helper_sqlite/src/helper_methods/:
|
|
- banner.ts (entire file — legacy duplicate, never imported)
|
|
- complaint.ts (entire file — legacy duplicate, never imported)
|
|
- const.ts (entire file — legacy duplicate, never imported)
|
|
- coupon.ts (entire file — legacy duplicate, never imported)
|
|
- order.ts (entire file — legacy duplicate, never imported)
|
|
- product.ts (entire file — legacy duplicate, never imported)
|
|
- slots.ts (entire file — legacy duplicate, never imported)
|
|
- staff-user.ts (entire file — legacy duplicate, never imported)
|
|
- store.ts (entire file — legacy duplicate, never imported)
|
|
- user.ts (entire file — legacy duplicate, never imported)
|
|
- vendor-snippets.ts (entire file — legacy duplicate, never imported)
|
|
|
|
Removed in packages/db_helper_postgres/src/helper_methods/: (same 11 files as above)
|
|
- banner.ts, complaint.ts, const.ts, coupon.ts, order.ts, product.ts, slots.ts, staff-user.ts, store.ts, user.ts, vendor-snippets.ts (entire files — legacy duplicates, never imported)
|
|
|
|
Removed in both packages (db_helper_sqlite + db_helper_postgres):
|
|
- src/user-apis/tags.ts (entire file — imported by no one)
|
|
- src/common-apis/utils.ts (entire file — imported by no one; formatDate/generateCode/calculateDiscount unreferenced)
|
|
- src/db/types.ts (entire file — imported by no one)
|
|
|
|
Kept: helper_methods/upload-url.ts (alive — re-exported by index.ts, used by backend).
|
|
|
|
Command: rm <each file listed above>
|
|
|
|
[2026-09-02 20:38:02] COMPLETED deletion of 28 dead files (DEAD_CODE_REPORT.md §1).
|
|
Verification:
|
|
- grep for 'helper_methods|user-apis/tags|common-apis/utils|db/types' across both packages + apps/backend: only remaining match is the live import of helper_methods/upload-url.ts in both index.ts files.
|
|
- tsc --noEmit on both packages reports pre-existing errors only (in untouched live files: src/db/seed.ts, src/user-apis/order.ts, src/user-apis/product.ts, src/admin-apis/complaint.ts, src/admin-apis/product.ts). No errors reference any deleted module.
|
|
|
|
[2026-09-02 20:45:45] DELETE dead exported methods per DEAD_CODE_REPORT.md §2a (8 symbols, both packages).
|
|
|
|
=== packages/db_helper_sqlite/src/admin-apis/product.ts ===
|
|
- removed getAllUnits (lines 650-657):
|
|
export async function getAllUnits(): Promise<AdminUnit[]> {
|
|
const allUnits = await db.query.units.findMany({
|
|
orderBy: units.shortNotation,
|
|
})
|
|
return allUnits.map(mapUnit)
|
|
}
|
|
- removed addProductToGroup (lines 1032-1034):
|
|
export async function addProductToGroup(groupId: number, productId: number): Promise<void> {
|
|
await db.insert(productGroupMembership).values({ groupId, productId })
|
|
}
|
|
- removed removeProductFromGroup (lines 1036-1042):
|
|
export async function removeProductFromGroup(groupId: number, productId: number): Promise<void> {
|
|
await db.delete(productGroupMembership)
|
|
.where(and(
|
|
eq(productGroupMembership.groupId, groupId),
|
|
eq(productGroupMembership.productId, productId)
|
|
))
|
|
}
|
|
|
|
=== packages/db_helper_postgres/src/admin-apis/product.ts ===
|
|
- identical removals (getAllUnits at 232-239, addProductToGroup at 496-498, removeProductFromGroup at 500-506)
|
|
|
|
=== packages/db_helper_sqlite/src/admin-apis/vendor-snippets.ts ===
|
|
- removed getOrderItemsByOrderIds (lines 196-209):
|
|
export async function getOrderItemsByOrderIds(orderIds: number[]) {
|
|
return await db.query.orderItems.findMany({
|
|
where: inArray(orderItems.orderId, orderIds),
|
|
with: { sku: { with: { product: true, features: true } } },
|
|
})
|
|
}
|
|
- removed getOrderStatusByOrderIds (lines 210-214):
|
|
export async function getOrderStatusByOrderIds(orderIds: number[]) {
|
|
return await db.query.orderStatus.findMany({
|
|
where: inArray(orderStatus.orderId, orderIds),
|
|
})
|
|
}
|
|
|
|
=== packages/db_helper_postgres/src/admin-apis/vendor-snippets.ts ===
|
|
- removed getOrderItemsByOrderIds (lines 188-200) — same signature; body joins product.unit instead of sku:
|
|
export async function getOrderItemsByOrderIds(orderIds: number[]) {
|
|
return await db.query.orderItems.findMany({
|
|
where: inArray(orderItems.orderId, orderIds),
|
|
with: { product: { with: { unit: true } } },
|
|
})
|
|
}
|
|
- removed getOrderStatusByOrderIds (lines 201-205) — identical to sqlite
|
|
|
|
=== packages/db_helper_sqlite/src/admin-apis/staff-user.ts + packages/db_helper_postgres/src/admin-apis/staff-user.ts ===
|
|
- removed updateUserSuspensionStatus (lines 101-109 in both) — duplicate of live upsertUserSuspension:
|
|
export async function updateUserSuspensionStatus(userId: number, isSuspended: boolean): Promise<void> {
|
|
await db
|
|
.insert(userDetails)
|
|
.values({ userId, isSuspended })
|
|
.onConflictDoUpdate({
|
|
target: userDetails.userId,
|
|
set: { isSuspended },
|
|
})
|
|
}
|
|
|
|
=== packages/db_helper_sqlite/src/user-apis/user.ts + packages/db_helper_postgres/src/user-apis/user.ts ===
|
|
- removed getUserWithCreds (lines 15-28 in both):
|
|
export async function getUserWithCreds(userId: number) {
|
|
const result = await db
|
|
.select()
|
|
.from(users)
|
|
.leftJoin(userCreds, eq(users.id, userCreds.userId))
|
|
.where(eq(users.id, userId))
|
|
.limit(1)
|
|
if (result.length === 0) return null
|
|
return { user: result[0].users, creds: result[0].user_creds }
|
|
}
|
|
|
|
=== packages/db_helper_sqlite/src/user-apis/auth.ts + packages/db_helper_postgres/src/user-apis/auth.ts ===
|
|
- removed createUserWithCreds (lines 145-168 in both):
|
|
export async function createUserWithCreds(input: { name; email; mobile; hashedPassword }) {
|
|
return db.transaction(async (tx) => { ...insert user, insert userCreds, return user... })
|
|
}
|
|
|
|
=== packages/db_helper_sqlite/index.ts (export list cleanup) ===
|
|
- removed line: getAllUnits,
|
|
- removed lines: addProductToGroup,
|
|
removeProductFromGroup,
|
|
- removed lines: getOrderItemsByOrderIds,
|
|
getOrderStatusByOrderIds,
|
|
- removed line: updateUserSuspensionStatus,
|
|
- removed line: getUserWithCreds as getUserWithCreds,
|
|
- removed line: createUserWithCreds as createUserAuthWithCreds,
|
|
|
|
=== packages/db_helper_postgres/index.ts (export list cleanup) ===
|
|
- same 8 export-line removals as sqlite index.ts
|
|
|
|
=== apps/backend/src/sqliteImporter.ts (re-export chain cleanup) ===
|
|
- removed line: getAllUnits,
|
|
- removed lines: addProductToGroup,
|
|
removeProductFromGroup,
|
|
- removed lines: getOrderItemsByOrderIds,
|
|
getOrderStatusByOrderIds,
|
|
- removed line: updateUserSuspensionStatus,
|
|
- removed line: createUserAuthWithCreds,
|
|
- removed line: getUserWithCreds,
|
|
|
|
Note: apps/backend/src/dbService.ts uses `export * from '@/src/sqliteImporter'` — no per-symbol change needed there.
|
|
Any imports left unused by these deletions (e.g. productGroupMembership, inArray, userCreds) will be removed in a follow-up entry if tsc/grep confirms they are unused.
|
|
|
|
[2026-09-02 20:49:23] FOLLOW-UP: remove imports/orphans left unused by §2a deletions.
|
|
|
|
=== packages/db_helper_sqlite/src/admin-apis/product.ts ===
|
|
- removed now-unused local type + mapper (only consumer was deleted getAllUnits):
|
|
line 103: type UnitRow = InferSelectModel<typeof units>
|
|
line 117: const mapUnit = (unit: UnitRow): AdminUnit => ({
|
|
id: unit.id,
|
|
shortNotation: unit.shortNotation,
|
|
fullName: unit.fullName,
|
|
})
|
|
(postgres product.ts keeps mapUnit — still used there at lines 111, 142)
|
|
|
|
=== packages/db_helper_sqlite/src/user-apis/user.ts ===
|
|
- import line 2: removed 'userCreds' from import { notifCreds, unloggedUserTokens, userCreds, userDetails, users } from '../db/schema'
|
|
|
|
=== packages/db_helper_postgres/src/user-apis/user.ts ===
|
|
- same import fix as sqlite user.ts
|
|
|
|
[2026-09-02 20:51:30] COMPLETED §2a deletion (8 dead exported methods, both packages + re-export chains).
|
|
Removed: getAllUnits, addProductToGroup, removeProductFromGroup, getOrderItemsByOrderIds, getOrderStatusByOrderIds, updateUserSuspensionStatus, getUserWithCreds, createUserWithCreds (+ orphaned mapUnit/UnitRow in sqlite product.ts, orphaned userCreds imports in both user.ts).
|
|
Verification:
|
|
- grep across packages + apps: zero live references remain (only commented lines in postgresImporter.ts).
|
|
- tsc --noEmit: sqlite = 4 errors (same as pre-change baseline), postgres = 40 errors (all pre-existing drizzle inference mismatches in untouched files), backend = 17 errors (all pre-existing, in untouched files). No error references any deleted symbol.
|
|
|
|
[2026-09-02 20:54:32] DELETE §2b/§2c dead exports + PARITY RENAME + RESTORE two methods for future use.
|
|
|
|
--- DELETIONS, packages/db_helper_sqlite/src/admin-apis/product.ts ---
|
|
- removed createSpecialDealsForSku (lines 1124-1145): inserts specialDeals rows keyed by skuId, returns mapped AdminSpecialDeal[]
|
|
- removed updateSkuDeals (lines 1147-1241): diff-based sync of specialDeals for a skuId (add/remove/update validTill)
|
|
- removed mergeSkus (lines 1243-1366, end of file): merges fromSkuId into toSkuId across orderItems, specialDeals, cartItems, couponApplicableProducts, JSON skuIds columns (deliverySlotInfo, homeBanners, coupons, reservedCoupons, vendorSnippets), keyValStore popularItems, then deletes skuFeatures + sku + orphaned product
|
|
|
|
--- DELETIONS, packages/db_helper_postgres/src/admin-apis/product.ts ---
|
|
- removed toggleProductOutOfStock (lines 181-203): flips productInfo.isOutOfStock
|
|
- removed createSpecialDealsForProduct (lines 677-698): postgres counterpart of createSpecialDealsForSku (keyed by productId)
|
|
- removed updateProductDeals (lines 700-775): postgres counterpart of updateSkuDeals
|
|
|
|
--- DELETION, packages/db_helper_postgres/src/lib/automated-jobs.ts ---
|
|
- removed toggleFlashDeliveryForItems (lines 10-16): bulk productInfo.isFlashAvailable update
|
|
- import line 2: removed 'productInfo' from import { productInfo, keyValStore } from '../db/schema'
|
|
- import line 3: removed 'inArray' from import { inArray, eq } from 'drizzle-orm'
|
|
|
|
--- EXPORT LIST, packages/db_helper_sqlite/index.ts ---
|
|
- removed lines: createSpecialDealsForSku,
|
|
updateSkuDeals,
|
|
mergeSkus,
|
|
|
|
--- EXPORT LIST, packages/db_helper_postgres/index.ts ---
|
|
- removed lines: createSpecialDealsForProduct,
|
|
updateProductDeals,
|
|
toggleProductOutOfStock,
|
|
- removed line: toggleFlashDeliveryForItems,
|
|
|
|
--- EXPORT LIST, apps/backend/src/sqliteImporter.ts ---
|
|
- removed lines: createSpecialDealsForSku,
|
|
updateSkuDeals,
|
|
mergeSkus,
|
|
|
|
--- PARITY RENAME, packages/db_helper_postgres/src/user-apis/product.ts ---
|
|
- renamed getSuspendedProductIds -> getSuspendedSkuIds (backend calls getSuspendedSkuIds; sqlite exports that name).
|
|
NOTE: implementation unchanged (queries productInfo.isSuspended) — postgres schema has no sku/marketStats model, so this is the closest postgres equivalent of the sqlite query on productMarketStats.skuId.
|
|
- packages/db_helper_postgres/index.ts: export line getSuspendedProductIds, -> getSuspendedSkuIds,
|
|
|
|
--- RESTORE (user request: needed in future), both packages ---
|
|
packages/db_helper_sqlite/src/user-apis/user.ts + packages/db_helper_postgres/src/user-apis/user.ts:
|
|
- re-added getUserWithCreds:
|
|
export async function getUserWithCreds(userId: number) {
|
|
const result = await db
|
|
.select()
|
|
.from(users)
|
|
.leftJoin(userCreds, eq(users.id, userCreds.userId))
|
|
.where(eq(users.id, userId))
|
|
.limit(1)
|
|
|
|
if (result.length === 0) return null
|
|
return {
|
|
user: result[0].users,
|
|
creds: result[0].user_creds,
|
|
}
|
|
}
|
|
- re-added 'userCreds' to the schema import line in both files.
|
|
|
|
packages/db_helper_sqlite/src/user-apis/auth.ts + packages/db_helper_postgres/src/user-apis/auth.ts:
|
|
- re-added createUserWithCreds:
|
|
export async function createUserWithCreds(input: {
|
|
name: string
|
|
email: string
|
|
mobile: string
|
|
hashedPassword: string
|
|
}) {
|
|
return db.transaction(async (tx) => {
|
|
const [user] = await tx.insert(users).values({
|
|
name: input.name,
|
|
email: input.email,
|
|
mobile: input.mobile,
|
|
}).returning()
|
|
|
|
await tx.insert(userCreds).values({
|
|
userId: user.id,
|
|
userPassword: input.hashedPassword,
|
|
})
|
|
|
|
return user
|
|
})
|
|
}
|
|
|
|
packages/db_helper_sqlite/index.ts + packages/db_helper_postgres/index.ts:
|
|
- re-added export lines: createUserWithCreds as createUserAuthWithCreds, (user auth block)
|
|
getUserWithCreds as getUserWithCreds, (user profile block)
|
|
|
|
apps/backend/src/sqliteImporter.ts:
|
|
- re-added re-export lines: createUserAuthWithCreds, and getUserWithCreds,
|
|
|
|
[2026-09-02 20:58:19] FOLLOW-UP: remove orphaned CreateSpecialDealInput (only consumers were the deleted deal functions; zero usages repo-wide).
|
|
|
|
=== packages/db_helper_sqlite/src/admin-apis/product.ts ===
|
|
- removed (line ~1118):
|
|
export interface CreateSpecialDealInput {
|
|
quantity: number
|
|
price: number
|
|
validTill: string | Date
|
|
}
|
|
|
|
=== packages/db_helper_postgres/src/admin-apis/product.ts ===
|
|
- removed identical interface (line ~647)
|
|
|
|
[2026-09-02 20:59:28] COMPLETED §2b/§2c deletions + parity rename + restoration of createUserWithCreds/getUserWithCreds.
|
|
Verification:
|
|
- grep: zero references to createSpecialDealsForSku, updateSkuDeals, mergeSkus, createSpecialDealsForProduct, updateProductDeals, toggleProductOutOfStock, toggleFlashDeliveryForItems, getSuspendedProductIds (only commented postgresImporter.ts lines excluded from check).
|
|
- Restored methods present in both packages' src + index.ts + backend sqliteImporter.ts.
|
|
- Postgres now exports getSuspendedSkuIds (renamed from getSuspendedProductIds) matching sqlite/backend usage.
|
|
- tsc --noEmit baselines unchanged: sqlite 4, postgres 40, backend 17 errors — all pre-existing, none reference touched symbols.
|
|
|
|
[2026-09-02 21:01:52] §3 EXPORT-ONLY DEAD cleanup: remove from index.ts (implementations kept), delete non-exported dead types.
|
|
|
|
=== packages/db_helper_sqlite/index.ts ===
|
|
- removed line 10 block: export { staffRoleEnum, staffPermissionEnum } from './src/db/schema'
|
|
(these enum values still flow to consumers via the existing `export * from './src/db/schema'` — the explicit line was redundant)
|
|
- user product block: removed type lines type SkuSummary,
|
|
type OffersPageData,
|
|
type OffersPageProductData,
|
|
- store helpers block: removed line type AvailabilityCacheData,
|
|
- user order block: removed type lines type OrderWithFullData,
|
|
type OrderWithCancellationData,
|
|
- SKU Features block: removed lines cleanFeatureValue,
|
|
splitQuantityFeature,
|
|
type SkuFeatureLike,
|
|
(kept composeUnitNotation, composeSkuName — used by backend)
|
|
|
|
=== packages/db_helper_postgres/index.ts ===
|
|
- removed line 11 block: export { staffRoleEnum, staffPermissionEnum } from './src/db/schema';
|
|
- user order block: removed type lines type OrderWithFullData,
|
|
type OrderWithCancellationData,
|
|
|
|
=== apps/backend/src/sqliteImporter.ts ===
|
|
- removed type lines type OrderWithFullData,
|
|
type OrderWithCancellationData,
|
|
- removed line getUserNotifCred,
|
|
|
|
Note: getNotifCred index export line in both packages: getNotifCred as getUserNotifCred, — removed (see below).
|
|
|
|
=== packages/db_helper_sqlite/index.ts + packages/db_helper_postgres/index.ts ===
|
|
- user profile block: removed line getNotifCred as getUserNotifCred,
|
|
(function getNotifCred kept in user.ts — called internally by upsertNotifCred)
|
|
|
|
=== packages/db_helper_sqlite/src/user-apis/order.ts ===
|
|
- removed dead interface (lines 33-40):
|
|
export interface PlaceOrderInput {
|
|
userId: number
|
|
selectedItems: OrderItemInput[]
|
|
addressId: number
|
|
paymentMethod: 'online' | 'cod'
|
|
couponId?: number
|
|
userNotes?: string
|
|
isFlash?: boolean
|
|
}
|
|
- removed dead interface (lines 43-51):
|
|
export interface OrderGroupData {
|
|
slotId: number | null
|
|
items: Array<{
|
|
productId: number
|
|
quantity: number
|
|
slotId: number | null
|
|
product: typeof productInfo.$inferSelect
|
|
}>
|
|
}
|
|
|
|
=== packages/db_helper_postgres/src/user-apis/order.ts ===
|
|
- removed identical PlaceOrderInput (lines 29-36) and OrderGroupData (lines 39-47)
|
|
|
|
[2026-09-02 21:04:10] CORRECTION to previous entry: while editing packages/db_helper_sqlite/index.ts user product block I accidentally removed getAllSkusSummary, getOffersAndCombos and type ProductSummaryData (all three are USED by backend). Immediately restored them; final state of that block keeps: getAllProductsWithUnits, getAllSkusSummary, getOffersAndCombos, type ProductSummaryData. Only type SkuSummary, type OffersPageData, type OffersPageProductData were meant to be (and now are) removed.
|
|
|
|
[2026-09-02 21:07:40] CORRECTION: while editing the user order block of packages/db_helper_sqlite/index.ts I accidentally removed getOrdersByIdsWithFullData and getOrderByIdWithFullData (both USED by backend post-order-handler). Immediately restored. Final state: those two functions kept; only type OrderWithFullData and type OrderWithCancellationData removed from that block. Also fixed an earlier accidental newline removal after the store-helpers export close brace.
|
|
|
|
[2026-09-02 21:05:24] FOLLOW-UP: remove orphaned OrderItemInput from user-apis/order.ts in both packages (its only consumer, PlaceOrderInput, was deleted; definition-only now).
|
|
|
|
=== packages/db_helper_sqlite/src/user-apis/order.ts ===
|
|
- removed (lines 27-31):
|
|
export interface OrderItemInput {
|
|
productId: number
|
|
quantity: number
|
|
slotId: number | null
|
|
}
|
|
|
|
=== packages/db_helper_postgres/src/user-apis/order.ts ===
|
|
- removed identical interface (lines 23-27)
|
|
|
|
[2026-09-02 21:06:16] COMPLETED §3 export-only-dead cleanup.
|
|
Removed from index.ts (implementations kept in src):
|
|
- both packages: redundant staffRoleEnum/staffPermissionEnum export block (still exported via `export * from './src/db/schema'`), type OrderWithFullData, type OrderWithCancellationData, getNotifCred as getUserNotifCred
|
|
- sqlite only: type SkuSummary, type OffersPageData, type OffersPageProductData, type AvailabilityCacheData, cleanFeatureValue, splitQuantityFeature, type SkuFeatureLike (kept composeUnitNotation/composeSkuName)
|
|
Removed from apps/backend/src/sqliteImporter.ts: type OrderWithFullData, type OrderWithCancellationData, getUserNotifCred
|
|
Deleted dead types in user-apis/order.ts (both packages): PlaceOrderInput, OrderGroupData, OrderItemInput
|
|
Verification:
|
|
- Backend-used exports confirmed intact: getAllSkusSummary, getOffersAndCombos, ProductSummaryData, getOrdersByIdsWithFullData, getOrderByIdWithFullData, getAvailabilityForCache, getAllProductCombosForCache, getUserWithCreds, createUserAuthWithCreds, composeSkuName, composeUnitNotation
|
|
- tsc --noEmit baselines unchanged: sqlite 4 (seed.ts 1, order.ts 2, product.ts 1), postgres 40, backend 17 — all pre-existing, none reference touched symbols.
|
|
|
|
[2026-09-02 21:21:13] §4: remove never-referenced schema tables — addressZones, addressAreas, userNotifications, productCategories (BOTH packages).
|
|
NOTE: this only removes them from the drizzle schema (code). The actual DB tables/columns/FK constraints still exist in D1/Postgres — dropping them in the DB requires a migration, which the user will handle (per AGENTS.md). Both schema.ts files drift from the live DB until then; drizzle-kit push/generate must NOT be run by the agent.
|
|
|
|
=== packages/db_helper_sqlite/src/db/schema.ts ===
|
|
- removed addressZones table (lines 106-110):
|
|
export const addressZones = sqliteTable('address_zones', {
|
|
id: integer().primaryKey({ autoIncrement: true }),
|
|
zoneName: text('zone_name').notNull(),
|
|
addedAt: timestampText('added_at').notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
})
|
|
- removed addressAreas table (lines 112-117):
|
|
export const addressAreas = sqliteTable('address_areas', {
|
|
id: integer().primaryKey({ autoIncrement: true }),
|
|
placeName: text('place_name').notNull(),
|
|
zoneId: integer('zone_id').references(() => addressZones.id),
|
|
createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
})
|
|
- addresses table: changed zoneId column to drop FK (column KEPT — shared UserAddress type and user-apis/address.ts mapUserAddress still expose zoneId):
|
|
before: zoneId: integer('zone_id').references(() => addressZones.id),
|
|
after: zoneId: integer('zone_id'),
|
|
- removed productCategories table (lines 431-434):
|
|
export const productCategories = sqliteTable('product_categories', {
|
|
id: integer().primaryKey({ autoIncrement: true }),
|
|
name: text().notNull(),
|
|
description: text(),
|
|
})
|
|
- removed userNotifications table (lines 545-551):
|
|
export const userNotifications = sqliteTable('user_notifications', {
|
|
id: integer().primaryKey({ autoIncrement: true }),
|
|
title: text('title').notNull(),
|
|
imageUrl: text('image_url'),
|
|
createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
body: text('body').notNull(),
|
|
applicableUsers: jsonText<number[] | null>('applicable_users'),
|
|
})
|
|
- addressesRelations: removed line zone: one(addressZones, { fields: [addresses.zoneId], references: [addressZones.id] }),
|
|
- removed productCategoriesRelations (line 686): export const productCategoriesRelations = relations(productCategories, ({}) => ({}))
|
|
- removed userNotificationsRelations (lines 720-722):
|
|
export const userNotificationsRelations = relations(userNotifications, ({}) => ({
|
|
// No relations needed for now
|
|
}))
|
|
- removed addressZonesRelations (lines 749-752):
|
|
export const addressZonesRelations = relations(addressZones, ({ many }) => ({
|
|
addresses: many(addresses),
|
|
areas: many(addressAreas),
|
|
}))
|
|
- removed addressAreasRelations (lines 754-756):
|
|
export const addressAreasRelations = relations(addressAreas, ({ one }) => ({
|
|
zone: one(addressZones, { fields: [addressAreas.zoneId], references: [addressZones.id] }),
|
|
}))
|
|
|
|
=== packages/db_helper_postgres/src/db/schema.ts === (same removals, postgres style)
|
|
- removed addressZones table (lines 58-62, mf.table('address_zones', ...))
|
|
- removed addressAreas table (lines 64-69, mf.table('address_areas', ...))
|
|
- addresses.zoneId (line 54): dropped .references(() => addressZones.id) — column kept
|
|
- removed productCategories table (lines 318-322, mf.table('product_categories', ...))
|
|
- removed userNotifications table (lines 434-440, mf.table('user_notifications', ...))
|
|
- addressesRelations: removed zone relation line (line 496)
|
|
- removed productCategoriesRelations (line 573)
|
|
- removed userNotificationsRelations (lines 607-609)
|
|
- removed addressZonesRelations (lines 636-639) and addressAreasRelations (lines 641-643)
|
|
|
|
[2026-09-02 21:23:14] COMPLETED §4 schema table removal.
|
|
- Removed from both packages' src/db/schema.ts: addressZones, addressAreas, productCategories, userNotifications tables + productCategoriesRelations, userNotificationsRelations, addressZonesRelations, addressAreasRelations.
|
|
- addresses.zoneId column KEPT (FK reference + addressesRelations.zone relation removed) because shared UserAddress type and user-apis/address.ts still expose zoneId.
|
|
- Verified: zero remaining references to the 4 tables anywhere; jsonText/jsonb/text imports still used by other tables; tsc baselines unchanged (sqlite 4, postgres 40, backend 17 — all pre-existing).
|
|
- REMINDER: DB tables still exist in D1/Postgres until the user runs a drop migration (agent must not run drizzle migrations).
|
|
|
|
[2026-09-02 21:24:48] §6: DELETE dead backend files (10 files) + clean commented references to them.
|
|
|
|
DELETED (all verified: zero live imports — only commented mentions remain):
|
|
- apps/backend/src/postgresImporter.ts (entirely commented-out swap scaffold; restore from git when swapping to postgres)
|
|
- apps/backend/src/lib/signed-url-cache-old.ts
|
|
- apps/backend/src/lib/signed-url-cache.ts
|
|
- apps/backend/src/lib/disk-persisted-set.ts (body fully commented out)
|
|
- apps/backend/src/lib/catch-async.ts
|
|
- apps/backend/src/lib/axios.ts (phonepeAxios never imported)
|
|
- apps/backend/src/lib/delete-image.ts (deleteS3Image never imported)
|
|
- apps/backend/src/lib/event-queue.ts (enqueue never imported; queue-consumer.ts is the live path)
|
|
- apps/backend/src/lib/notif-service.ts
|
|
- apps/backend/src/types/db.types.ts
|
|
|
|
COMMENT CLEANUP (files are .ts → logged here):
|
|
=== apps/backend/index.ts ===
|
|
- removed line 5: // import signedUrlCache from '@/src/lib/signed-url-cache';
|
|
- removed line 12: // signedUrlCache.loadFromDisk(); // Disabled for Workers compatibility
|
|
Left untouched: s3-client.ts:141 prose comment (mentions the concept, not an import), dbService.ts prose header.
|
|
KEPT (verified alive): jobs/cache-creator.ts (Durable Object), lib/queue-consumer.ts, lib/flash-delivery-cron.ts, lib/seed.ts, lib/init.ts, lib/worker-init.ts, src/apis/**, src/test-controller.ts, types/hono.d.ts (ambient).
|
|
|
|
[2026-09-02 21:25:58] COMPLETED §6 backend dead-file deletion (10 files) + index.ts comment cleanup.
|
|
Verification: backend tsc --noEmit now reports 11 errors (was 17) — the 6 that vanished were signed-url-cache-old.ts's own pre-existing errors; remaining 11 are the same pre-existing set in untouched files (app.ts, lib/init.ts, s3-client.ts, main-router.ts, trpc-index.ts, sqlite order.ts/product.ts). No new errors.
|
|
Note: apps/backend/src/lib/s3-client.ts.txt (a .txt copy of s3-client) still exists — left alone, flagging as possible future cleanup.
|
|
|
|
[2026-09-02 21:31:17] Remove 4 dead-code items missed by our report but caught by cmd_v4_dead.md.
|
|
|
|
DELETED (3 files, verified zero live imports — only commented references):
|
|
- apps/backend/src/lib/redis-client.ts (stubbed: createClient = (args:any) => {}; only '// import redisClient' comments remain elsewhere)
|
|
- apps/backend/src/lib/redisKeyGetters.ts (only commented imports in trpc/apis/admin-apis/apis/slots.ts:7,613,694)
|
|
- apps/backend/src/middleware/auth.ts (verifyToken/requireRole never imported; app uses middleware/auth.middleware.ts + staff-auth.ts)
|
|
|
|
EDITED:
|
|
=== packages/shared/index.ts ===
|
|
- removed line 10 (dead type, definition-only):
|
|
export type CacheFilename = typeof CACHE_FILENAMES[keyof typeof CACHE_FILENAMES]
|
|
(CACHE_FILENAMES const itself is heavily used by backend cloud_cache.ts and web-ui/user-ui hooks — kept)
|
|
|
|
[2026-09-02 21:32:23] COMPLETED removal of 4 missed dead-code items.
|
|
- Deleted: apps/backend/src/lib/redis-client.ts, apps/backend/src/lib/redisKeyGetters.ts, apps/backend/src/middleware/auth.ts (middleware/ dir still has auth.middleware.ts + staff-auth.ts).
|
|
- Removed CacheFilename type from packages/shared/index.ts (CACHE_FILENAMES const kept — used by cloud_cache.ts + web-ui/user-ui hooks).
|
|
- Verified: zero remaining references (excluding comments); backend tsc --noEmit = 11 errors, same pre-existing baseline.
|