This commit introduces several new scripts for managing database operations, including user creation, permission grants, and data migrations. It also adds new documentation files to guide users through the setup and configuration processes. Additionally, the project structure is updated to enhance organization and maintainability, ensuring a smoother development experience for contributors. These changes support the ongoing transition to a web-based architecture and improve overall project functionality.
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import { PrismaClient as PrismaClientAuth } from '../node_modules/.prisma/client-auth';
|
|
import * as dotenv from 'dotenv';
|
|
|
|
// Load environment variables
|
|
dotenv.config({ path: '.env' });
|
|
|
|
const prisma = new PrismaClientAuth({
|
|
datasourceUrl: process.env.DATABASE_URL_AUTH,
|
|
});
|
|
|
|
async function testAdminCheck() {
|
|
try {
|
|
console.log('Testing admin user check...\n');
|
|
|
|
// Find admin user
|
|
const admin = await prisma.user.findUnique({
|
|
where: { email: 'admin@admin.com' },
|
|
select: {
|
|
id: true,
|
|
email: true,
|
|
name: true,
|
|
isAdmin: true,
|
|
hasWriteAccess: true,
|
|
},
|
|
});
|
|
|
|
if (!admin) {
|
|
console.log('❌ Admin user not found!');
|
|
return;
|
|
}
|
|
|
|
console.log('✅ Admin user found:');
|
|
console.log(' ID:', admin.id);
|
|
console.log(' Email:', admin.email);
|
|
console.log(' Is Admin:', admin.isAdmin);
|
|
console.log(' Has Write Access:', admin.hasWriteAccess);
|
|
|
|
// Test querying all users (like the API does)
|
|
console.log('\nTesting user list query...');
|
|
const users = await prisma.user.findMany({
|
|
select: {
|
|
id: true,
|
|
email: true,
|
|
name: true,
|
|
isAdmin: true,
|
|
hasWriteAccess: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
},
|
|
orderBy: {
|
|
createdAt: 'desc',
|
|
},
|
|
});
|
|
|
|
console.log(`✅ Successfully queried ${users.length} users`);
|
|
users.forEach((user, index) => {
|
|
console.log(` ${index + 1}. ${user.email} (Admin: ${user.isAdmin}, Write: ${user.hasWriteAccess})`);
|
|
});
|
|
|
|
console.log('\n✅ All checks passed!');
|
|
} catch (error: any) {
|
|
console.error('\n❌ Error:', error.message);
|
|
console.error('Stack:', error.stack);
|
|
} finally {
|
|
await prisma.$disconnect();
|
|
}
|
|
}
|
|
|
|
testAdminCheck();
|
|
|