Initial commit
This commit is contained in:
97
backend/prisma/seed.js
Normal file
97
backend/prisma/seed.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('🌱 Seeding database...');
|
||||
|
||||
// Create admin user
|
||||
const adminPassword = await bcrypt.hash('admin123', 12);
|
||||
const admin = await prisma.user.upsert({
|
||||
where: { email: 'admin@lnpaywall.com' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'admin@lnpaywall.com',
|
||||
passwordHash: adminPassword,
|
||||
displayName: 'Admin',
|
||||
role: 'ADMIN',
|
||||
emailVerified: true,
|
||||
},
|
||||
});
|
||||
console.log('✅ Created admin user:', admin.email);
|
||||
|
||||
// Create demo creator
|
||||
const creatorPassword = await bcrypt.hash('demo123', 12);
|
||||
const creator = await prisma.user.upsert({
|
||||
where: { email: 'creator@demo.com' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'creator@demo.com',
|
||||
passwordHash: creatorPassword,
|
||||
displayName: 'Demo Creator',
|
||||
role: 'CREATOR',
|
||||
emailVerified: true,
|
||||
lightningAddress: 'demo@getalby.com',
|
||||
},
|
||||
});
|
||||
console.log('✅ Created demo creator:', creator.email);
|
||||
|
||||
// Create sample paywalls
|
||||
const paywalls = [
|
||||
{
|
||||
title: 'Complete Bitcoin Development Course',
|
||||
description: 'Learn to build on Bitcoin and Lightning Network from scratch. 10+ hours of video content.',
|
||||
originalUrl: 'https://example.com/bitcoin-course',
|
||||
originalUrlType: 'URL',
|
||||
priceSats: 5000,
|
||||
slug: 'bitcoin-course',
|
||||
coverImageUrl: 'https://images.unsplash.com/photo-1621761191319-c6fb62004040?w=800',
|
||||
},
|
||||
{
|
||||
title: 'Exclusive Trading Strategy PDF',
|
||||
description: 'My personal trading strategy that generates consistent returns. Includes spreadsheet templates.',
|
||||
originalUrl: 'https://example.com/trading-guide.pdf',
|
||||
originalUrlType: 'PDF',
|
||||
priceSats: 2100,
|
||||
slug: 'trading-strategy',
|
||||
coverImageUrl: 'https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?w=800',
|
||||
},
|
||||
{
|
||||
title: 'Private Notion Template Library',
|
||||
description: 'Access my complete collection of 50+ Notion templates for productivity and business.',
|
||||
originalUrl: 'https://notion.so/template-library',
|
||||
originalUrlType: 'NOTION',
|
||||
priceSats: 1000,
|
||||
slug: 'notion-templates',
|
||||
coverImageUrl: 'https://images.unsplash.com/photo-1484480974693-6ca0a78fb36b?w=800',
|
||||
},
|
||||
];
|
||||
|
||||
for (const paywallData of paywalls) {
|
||||
const paywall = await prisma.paywall.upsert({
|
||||
where: { slug: paywallData.slug },
|
||||
update: {},
|
||||
create: {
|
||||
...paywallData,
|
||||
creatorId: creator.id,
|
||||
},
|
||||
});
|
||||
console.log('✅ Created paywall:', paywall.title);
|
||||
}
|
||||
|
||||
console.log('\n🎉 Seeding complete!');
|
||||
console.log('\n📝 Test accounts:');
|
||||
console.log(' Admin: admin@lnpaywall.com / admin123');
|
||||
console.log(' Creator: creator@demo.com / demo123');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error('❌ Seed error:', e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user