| 7 | import { db, categories, sources, distros, apps } from '../src/db'; |
| 8 | |
| 9 | async function checkData() { |
| 10 | console.log('🔍 Checking database for seeded data...\n'); |
| 11 | |
| 12 | try { |
| 13 | const categoriesLength = (await db.select().from(categories)).length; |
| 14 | const sourcesLength = (await db.select().from(sources)).length; |
| 15 | const distrosLength = (await db.select().from(distros)).length; |
| 16 | const appsLength = (await db.select().from(apps)).length; |
| 17 | |
| 18 | console.log('📊 Database Status:'); |
| 19 | console.log(` Categories: ${categoriesLength}`); |
| 20 | console.log(` Sources: ${sourcesLength}`); |
| 21 | console.log(` Distros: ${distrosLength}`); |
| 22 | console.log(` Apps: ${appsLength}\n`); |
| 23 | |
| 24 | if (categoriesLength === 0 || sourcesLength === 0 || distrosLength === 0) { |
| 25 | console.log('❌ Database is not properly seeded!'); |
| 26 | console.log('\n💡 To seed the database, run: bun run db:seed\n'); |
| 27 | process.exit(1); |
| 28 | } else { |
| 29 | console.log('✅ Database is properly seeded and ready to use!\n'); |
| 30 | process.exit(0); |
| 31 | } |
| 32 | } catch (error) { |
| 33 | console.error('❌ Error checking database:', error); |
| 34 | process.exit(1); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | await checkData(); |