52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import bcrypt from 'bcryptjs';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const passwordHash = await bcrypt.hash('password123', 12);
|
|
|
|
const user = await prisma.user.upsert({
|
|
where: { email: 'dev@yetanothersuite.dev' },
|
|
update: {},
|
|
create: {
|
|
email: 'dev@yetanothersuite.dev',
|
|
passwordHash,
|
|
displayName: 'Dev User',
|
|
preferences: {
|
|
theme: 'system',
|
|
timezone: 'UTC',
|
|
notificationSettings: { push: true, email: true, inApp: true },
|
|
defaultViews: { tasks: 'list', calendar: 'week', notes: 'list' },
|
|
},
|
|
},
|
|
});
|
|
|
|
const workspace = await prisma.workspace.upsert({
|
|
where: { slug_ownerId: { slug: 'personal', ownerId: user.id } },
|
|
update: {},
|
|
create: {
|
|
name: 'Personal',
|
|
slug: 'personal',
|
|
description: 'My personal workspace',
|
|
ownerId: user.id,
|
|
settings: {
|
|
defaultView: 'list',
|
|
aiEnabled: true,
|
|
retentionPolicy: 'forever',
|
|
},
|
|
},
|
|
});
|
|
|
|
console.log({ user: user.id, workspace: workspace.id });
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|