57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log('Seeding database...');
|
|
|
|
// Create some sample files
|
|
const sampleFiles = [
|
|
{
|
|
filename: 'sample-image-1.jpg',
|
|
originalName: 'Beautiful Landscape.jpg',
|
|
fileType: 'image',
|
|
fileSize: 1024000,
|
|
filePath: '/uploads/images/sample-image-1.jpg',
|
|
mimeType: 'image/jpeg',
|
|
isVisible: true,
|
|
},
|
|
{
|
|
filename: 'sample-image-2.png',
|
|
originalName: 'City View.png',
|
|
fileType: 'image',
|
|
fileSize: 2048000,
|
|
filePath: '/uploads/images/sample-image-2.png',
|
|
mimeType: 'image/png',
|
|
isVisible: true,
|
|
},
|
|
{
|
|
filename: 'sample-video-1.mp4',
|
|
originalName: 'Nature Video.mp4',
|
|
fileType: 'video',
|
|
fileSize: 10485760,
|
|
filePath: '/uploads/videos/sample-video-1.mp4',
|
|
mimeType: 'video/mp4',
|
|
isVisible: true,
|
|
},
|
|
];
|
|
|
|
for (const file of sampleFiles) {
|
|
await prisma.file.upsert({
|
|
where: { filename: file.filename },
|
|
update: {},
|
|
create: file,
|
|
});
|
|
}
|
|
|
|
console.log('Database seeded successfully!');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
}); |