MaternAlert / src /check-and-update-super-admin.ts
Auspicious14's picture
feat(ocr, risk): add patient OCR and risk assessment
27e706d
Raw
History Blame Contribute Delete
1.26 kB
import { PrismaClient } from "@prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";
import { Pool } from "pg";
import * as dotenv from "dotenv";
// Load environment variables
dotenv.config();
// Initialize Prisma Client with adapter
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false,
},
});
const prisma = new PrismaClient({
adapter: new PrismaPg(pool),
});
async function main() {
const user = await prisma.userAuth.findUnique({
where: { email: "healthworker1@maternalert.com" },
});
console.log("Current user:", user);
const updateData: any = {};
let needsUpdate = false;
// if (user?.role !== "SUPER_ADMIN") {
// updateData.role = "SUPER_ADMIN";
// needsUpdate = true;
// }
if (user?.status !== "ACTIVE") {
updateData.status = "ACTIVE";
needsUpdate = true;
}
if (needsUpdate) {
console.log("Updating super admin...");
await prisma.userAuth.update({
where: { email: "healthworker1@maternalert.com" },
data: updateData,
});
console.log("Super admin updated!");
}
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});