NAS deployment fixed
This commit is contained in:
@@ -1,13 +1,48 @@
|
||||
// Simple script to check for admin user
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
(async () => {
|
||||
const prisma = new PrismaClient();
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
async function checkAdmin() {
|
||||
process.env.APP_MODE = 'prod';
|
||||
|
||||
// Attempt to locate database path similar to production
|
||||
let dbPath = './server/prod.db';
|
||||
if (!fs.existsSync(dbPath)) {
|
||||
dbPath = './prod.db'; // If running from inside server dir
|
||||
}
|
||||
|
||||
console.log(`Checking database at: ${path.resolve(dbPath)}`);
|
||||
console.log(`File exists: ${fs.existsSync(dbPath)}`);
|
||||
|
||||
if (!fs.existsSync(dbPath)) {
|
||||
console.error('CRITICAL: Database file not found! Ensure pm2 is running from the correct directory.');
|
||||
return;
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient({
|
||||
datasources: {
|
||||
db: {
|
||||
url: `file:${path.resolve(dbPath)}`,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const admin = await prisma.user.findFirst({ where: { role: 'ADMIN' } });
|
||||
console.log('Admin user:', admin);
|
||||
} catch (e) {
|
||||
console.error('Error:', e);
|
||||
const admin = await prisma.user.findFirst({
|
||||
where: { role: 'ADMIN' },
|
||||
});
|
||||
|
||||
if (admin) {
|
||||
console.log(`✅ Admin user found: ${admin.email}`);
|
||||
console.log(`First login: ${admin.isFirstLogin}`);
|
||||
} else {
|
||||
console.log('❌ No admin user found in database.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error connecting to database:', error.message);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
checkAdmin();
|
||||
|
||||
Reference in New Issue
Block a user