forked from nyashaushe/Color-Tech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-db.js
More file actions
63 lines (53 loc) · 2.77 KB
/
check-db.js
File metadata and controls
63 lines (53 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { PrismaClient } from '@prisma/client';
async function checkDatabase() {
const prisma = new PrismaClient();
try {
console.log('🔍 Checking database contents...\n');
const userCount = await prisma.user.count();
const postCount = await prisma.post.count();
const serviceCount = await prisma.service.count();
const galleryCount = await prisma.galleryItem.count();
const testimonialCount = await prisma.testimonial.count();
const faqCount = await prisma.fAQ.count();
const bookingCount = await prisma.booking.count();
const reviewCount = await prisma.review.count();
const homepageSectionCount = await prisma.homepageSection.count();
console.log('📊 Database Record Counts:');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log(`👥 Users: ${userCount}`);
console.log(`📝 Blog Posts: ${postCount}`);
console.log(`🔧 Services: ${serviceCount}`);
console.log(`🖼️ Gallery Items: ${galleryCount}`);
console.log(`💬 Testimonials: ${testimonialCount}`);
console.log(`❓ FAQs: ${faqCount}`);
console.log(`📅 Bookings: ${bookingCount}`);
console.log(`⭐ Reviews: ${reviewCount}`);
console.log(`🏠 Homepage Sections: ${homepageSectionCount}`);
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
if (userCount > 0) {
console.log('👤 Sample Users:');
const users = await prisma.user.findMany({ take: 3, select: { id: true, name: true, email: true, role: true } });
users.forEach(user => console.log(` - ${user.name} (${user.email}) - ${user.role}`));
console.log('');
}
if (postCount > 0) {
console.log('📖 Sample Blog Posts:');
const posts = await prisma.post.findMany({ take: 3, select: { title: true, isPublished: true } });
posts.forEach(post => console.log(` - ${post.title} ${post.isPublished ? '✅' : '❌'}`));
console.log('');
}
if (serviceCount > 0) {
console.log('🔧 Available Services:');
const services = await prisma.service.findMany({ take: 5, select: { name: true, status: true } });
services.forEach(service => console.log(` - ${service.name} (${service.status})`));
console.log('');
}
console.log('✅ Database connection successful!');
console.log('✅ All data has been migrated to your new Neon database!');
} catch (error) {
console.error('❌ Database connection failed:', error.message);
} finally {
await prisma.$disconnect();
}
}
checkDatabase();