Add 5 realistic fake clients to seed data
This commit is contained in:
114
src/db/seed.ts
114
src/db/seed.ts
@@ -1,8 +1,87 @@
|
||||
import { db } from './index';
|
||||
import { users, accounts } from './schema';
|
||||
import { users, accounts, clients } from './schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { hashPassword } from 'better-auth/crypto';
|
||||
|
||||
const fakeClients = [
|
||||
{
|
||||
firstName: 'Sarah',
|
||||
lastName: 'Mitchell',
|
||||
email: 'sarah.mitchell@email.com',
|
||||
phone: '(555) 234-5678',
|
||||
company: 'Mitchell & Associates',
|
||||
role: 'Managing Partner',
|
||||
city: 'Austin',
|
||||
state: 'TX',
|
||||
birthday: new Date('1978-06-15'),
|
||||
anniversary: new Date('2005-09-20'),
|
||||
interests: ['golf', 'wine collecting', 'travel'],
|
||||
family: { spouse: 'David', children: ['Emma', 'Jack'] },
|
||||
notes: 'Very interested in sustainable investing. Prefers morning meetings.',
|
||||
tags: ['high-value', 'quarterly-review'],
|
||||
},
|
||||
{
|
||||
firstName: 'Marcus',
|
||||
lastName: 'Johnson',
|
||||
email: 'marcus.j@techventures.io',
|
||||
phone: '(555) 876-5432',
|
||||
company: 'TechVentures Capital',
|
||||
role: 'CEO',
|
||||
city: 'San Francisco',
|
||||
state: 'CA',
|
||||
birthday: new Date('1985-03-22'),
|
||||
interests: ['startups', 'AI', 'marathon running', 'podcasts'],
|
||||
family: { spouse: 'Michelle' },
|
||||
notes: 'Recently sold his startup. Looking for aggressive growth strategies.',
|
||||
tags: ['new-client', 'tech'],
|
||||
},
|
||||
{
|
||||
firstName: 'Linda',
|
||||
lastName: 'Chen',
|
||||
email: 'lchen@globalhealth.org',
|
||||
phone: '(555) 345-9876',
|
||||
company: 'Global Health Foundation',
|
||||
role: 'Executive Director',
|
||||
city: 'Seattle',
|
||||
state: 'WA',
|
||||
birthday: new Date('1972-11-08'),
|
||||
anniversary: new Date('1998-07-12'),
|
||||
interests: ['philanthropy', 'hiking', 'classical music', 'book clubs'],
|
||||
family: { spouse: 'Robert', children: ['Olivia', 'Noah', 'Sophia'] },
|
||||
notes: 'Focused on legacy planning and charitable giving. Daughter Olivia graduating medical school in May.',
|
||||
tags: ['philanthropy', 'estate-planning'],
|
||||
},
|
||||
{
|
||||
firstName: 'James',
|
||||
lastName: 'Rodriguez',
|
||||
email: 'james.rodriguez@email.com',
|
||||
phone: '(555) 567-8901',
|
||||
company: 'Rodriguez Construction',
|
||||
role: 'Owner',
|
||||
city: 'Phoenix',
|
||||
state: 'AZ',
|
||||
birthday: new Date('1968-09-30'),
|
||||
interests: ['fishing', 'classic cars', 'football'],
|
||||
family: { spouse: 'Maria', children: ['Carlos', 'Isabella'] },
|
||||
notes: 'Planning to retire in 5 years. Wants to transition business to son Carlos.',
|
||||
tags: ['retirement', 'business-succession'],
|
||||
},
|
||||
{
|
||||
firstName: 'Emily',
|
||||
lastName: 'Watson',
|
||||
email: 'emily.watson@lawfirm.com',
|
||||
phone: '(555) 432-1098',
|
||||
company: 'Watson Legal Group',
|
||||
role: 'Senior Partner',
|
||||
city: 'Chicago',
|
||||
state: 'IL',
|
||||
birthday: new Date('1980-04-17'),
|
||||
interests: ['art collecting', 'yoga', 'french cuisine'],
|
||||
notes: 'Recently divorced. Needs portfolio restructuring. Interested in real estate investments.',
|
||||
tags: ['life-change', 'real-estate'],
|
||||
},
|
||||
];
|
||||
|
||||
async function seed() {
|
||||
const testEmail = 'test@test.com';
|
||||
|
||||
@@ -12,13 +91,14 @@ async function seed() {
|
||||
.where(eq(users.email, testEmail))
|
||||
.limit(1);
|
||||
|
||||
let userId: string;
|
||||
|
||||
if (existing) {
|
||||
console.log('✓ Test user already exists');
|
||||
return;
|
||||
}
|
||||
|
||||
userId = existing.id;
|
||||
} else {
|
||||
// Create test user
|
||||
const userId = crypto.randomUUID();
|
||||
userId = crypto.randomUUID();
|
||||
const hashedPassword = await hashPassword('test');
|
||||
|
||||
await db.insert(users).values({
|
||||
@@ -42,6 +122,30 @@ async function seed() {
|
||||
});
|
||||
|
||||
console.log('✓ Created test user: test@test.com / test');
|
||||
}
|
||||
|
||||
// Check if fake clients already exist (check for Sarah Mitchell specifically)
|
||||
const [existingFakeClient] = await db.select()
|
||||
.from(clients)
|
||||
.where(eq(clients.email, 'sarah.mitchell@email.com'))
|
||||
.limit(1);
|
||||
|
||||
if (existingFakeClient) {
|
||||
console.log('✓ Test clients already exist');
|
||||
return;
|
||||
}
|
||||
|
||||
// Add fake clients
|
||||
for (const client of fakeClients) {
|
||||
await db.insert(clients).values({
|
||||
userId,
|
||||
...client,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`✓ Created ${fakeClients.length} test clients`);
|
||||
}
|
||||
|
||||
seed()
|
||||
|
||||
Reference in New Issue
Block a user