import { db } from '@/db'; import { clients, phases, tasks, deliverables, payments, documents, notes, } from '@/db/schema'; import { nanoid } from 'nanoid'; async function seed() { console.log('🌱 Seeding database...\n'); try { const clientToken = nanoid(); const [client] = await db .insert(clients) .values({ name: 'Test Client Inc.', brand_name: 'TestBrand', brief: 'A comprehensive personal branding overhaul, positioning as a premium consultancy in the digital transformation space.', token: clientToken, accepted_total: '5000.00', }) .returning(); console.log(`āœ“ Client created: ${client.name} (ID: ${client.id})`); const [phase1, phase2, phase3] = await db .insert(phases) .values([ { client_id: client.id, title: 'Discovery & Strategy', sort_order: 1, status: 'done' }, { client_id: client.id, title: 'Design & Messaging', sort_order: 2, status: 'active' }, { client_id: client.id, title: 'Implementation & Launch', sort_order: 3, status: 'upcoming' }, ]) .returning(); console.log('āœ“ Phases created (3 total)'); const [task1, task2, task3, task4, task5, task6] = await db .insert(tasks) .values([ { phase_id: phase1.id, title: 'Stakeholder interviews', description: 'In-depth conversations with leadership team', sort_order: 1, status: 'done' }, { phase_id: phase1.id, title: 'Competitive analysis', description: 'Research top 10 competitors in the space', sort_order: 2, status: 'done' }, { phase_id: phase2.id, title: 'Brand positioning document', description: 'Write and refine the core positioning statement', sort_order: 1, status: 'in_progress' }, { phase_id: phase2.id, title: 'Visual identity design', description: 'Logo, color palette, typography', sort_order: 2, status: 'in_progress' }, { phase_id: phase3.id, title: 'Website build & launch', description: 'Design and develop new company website', sort_order: 1, status: 'todo' }, { phase_id: phase3.id, title: 'Social media rollout', description: 'Launch branded social media accounts', sort_order: 2, status: 'todo' }, ]) .returning(); console.log('āœ“ Tasks created (6 total)'); await db .insert(deliverables) .values([ { task_id: task1.id, title: 'Interview notes & synthesis', url: 'https://docs.google.com/document/d/1example', status: 'approved', approved_at: new Date('2026-04-15') }, { task_id: task2.id, title: 'Competitive landscape report', url: 'https://docs.google.com/presentation/d/1example', status: 'approved', approved_at: new Date('2026-04-20') }, { task_id: task3.id, title: 'Brand positioning document (draft)', url: 'https://docs.google.com/document/d/2example', status: 'submitted', approved_at: null }, { task_id: task4.id, title: 'Logo concepts (3 variations)', url: 'https://www.figma.com/file/example', status: 'pending', approved_at: null }, ]); console.log('āœ“ Deliverables created (4 total)'); await db .insert(payments) .values([ { client_id: client.id, label: 'Acconto 50%', amount: '2500.00', status: 'saldato', paid_at: new Date('2026-04-01') }, { client_id: client.id, label: 'Saldo 50%', amount: '2500.00', status: 'inviata', paid_at: null }, ]); console.log('āœ“ Payments created (2 total)'); await db .insert(documents) .values([ { client_id: client.id, label: 'Brand Guidelines PDF', url: 'https://example.com/brand-guidelines.pdf' }, { client_id: client.id, label: 'Design Mockups Figma', url: 'https://www.figma.com/file/example' }, ]); console.log('āœ“ Documents created (2 total)'); await db .insert(notes) .values([ { client_id: client.id, body: 'Initial strategy session completed. Key insight: positioning needs to emphasize tech expertise and creative thinking balance.', created_at: new Date('2026-04-10') }, { client_id: client.id, body: 'Phase 1 approved. Moving forward with design phase. Stakeholders excited about direction.', created_at: new Date('2026-04-22') }, ]); console.log('āœ“ Notes created (2 total)'); console.log('\n✨ Seed complete!\n'); console.log('šŸ“Ž Shareable client link:'); console.log(` http://localhost:3000/c/${clientToken}\n`); console.log('This link is unique and secret. Send it to the client via Slack or email.\n'); process.exit(0); } catch (error) { console.error('āŒ Seed failed:', error); process.exit(1); } } seed();