feat(06-01): migrate categories from emoji to Lucide icon field
- Rename emoji column to icon in schema, Zod schemas, and all services - Add Drizzle migration with emoji-to-icon data conversion - Update test helper, seed, and all test files for icon field - All 87 tests pass with new icon-based schema Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,13 +10,13 @@ export function getAllCategories(db: Db = prodDb) {
|
||||
|
||||
export function createCategory(
|
||||
db: Db = prodDb,
|
||||
data: { name: string; emoji?: string },
|
||||
data: { name: string; icon?: string },
|
||||
) {
|
||||
return db
|
||||
.insert(categories)
|
||||
.values({
|
||||
name: data.name,
|
||||
...(data.emoji ? { emoji: data.emoji } : {}),
|
||||
...(data.icon ? { icon: data.icon } : {}),
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
@@ -25,7 +25,7 @@ export function createCategory(
|
||||
export function updateCategory(
|
||||
db: Db = prodDb,
|
||||
id: number,
|
||||
data: { name?: string; emoji?: string },
|
||||
data: { name?: string; icon?: string },
|
||||
) {
|
||||
const existing = db
|
||||
.select({ id: categories.id })
|
||||
|
||||
@@ -19,7 +19,7 @@ export function getAllItems(db: Db = prodDb) {
|
||||
createdAt: items.createdAt,
|
||||
updatedAt: items.updatedAt,
|
||||
categoryName: categories.name,
|
||||
categoryEmoji: categories.emoji,
|
||||
categoryIcon: categories.icon,
|
||||
})
|
||||
.from(items)
|
||||
.innerJoin(categories, eq(items.categoryId, categories.id))
|
||||
|
||||
@@ -57,7 +57,7 @@ export function getSetupWithItems(db: Db = prodDb, setupId: number) {
|
||||
createdAt: items.createdAt,
|
||||
updatedAt: items.updatedAt,
|
||||
categoryName: categories.name,
|
||||
categoryEmoji: categories.emoji,
|
||||
categoryIcon: categories.icon,
|
||||
})
|
||||
.from(setupItems)
|
||||
.innerJoin(items, eq(setupItems.itemId, items.id))
|
||||
|
||||
@@ -22,7 +22,7 @@ export function getAllThreads(db: Db = prodDb, includeResolved = false) {
|
||||
resolvedCandidateId: threads.resolvedCandidateId,
|
||||
categoryId: threads.categoryId,
|
||||
categoryName: categories.name,
|
||||
categoryEmoji: categories.emoji,
|
||||
categoryIcon: categories.icon,
|
||||
createdAt: threads.createdAt,
|
||||
updatedAt: threads.updatedAt,
|
||||
candidateCount: sql<number>`(
|
||||
@@ -67,7 +67,7 @@ export function getThreadWithCandidates(db: Db = prodDb, threadId: number) {
|
||||
createdAt: threadCandidates.createdAt,
|
||||
updatedAt: threadCandidates.updatedAt,
|
||||
categoryName: categories.name,
|
||||
categoryEmoji: categories.emoji,
|
||||
categoryIcon: categories.icon,
|
||||
})
|
||||
.from(threadCandidates)
|
||||
.innerJoin(categories, eq(threadCandidates.categoryId, categories.id))
|
||||
|
||||
@@ -9,7 +9,7 @@ export function getCategoryTotals(db: Db = prodDb) {
|
||||
.select({
|
||||
categoryId: items.categoryId,
|
||||
categoryName: categories.name,
|
||||
categoryEmoji: categories.emoji,
|
||||
categoryIcon: categories.icon,
|
||||
totalWeight: sql<number>`COALESCE(SUM(${items.weightGrams}), 0)`,
|
||||
totalCost: sql<number>`COALESCE(SUM(${items.priceCents}), 0)`,
|
||||
itemCount: sql<number>`COUNT(*)`,
|
||||
|
||||
Reference in New Issue
Block a user