mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 17:42:00 +00:00
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 3m9s
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import { PrismaClient } from "@prisma/client";
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
const DEFAULT_ISLANDS = ["Dharanboodhoo", "Feeali", "Nilandhoo", "Magoodhoo"];
|
|
|
|
async function main() {
|
|
await prisma.user.upsert({
|
|
where: {
|
|
phoneNumber: process.env.ADMIN_PHONENUMBER,
|
|
},
|
|
update: {},
|
|
create: {
|
|
name: process.env.ADMIN_FULLNAME,
|
|
email: process.env.ADMIN_EMAIL,
|
|
emailVerified: true,
|
|
verified: true,
|
|
address: process.env.ADMIN_ADDRESS,
|
|
id_card: process.env.ADMIN_IDCARD,
|
|
dob: new Date("1999-05-06"),
|
|
phoneNumber: process.env.ADMIN_PHONENUMBER ?? "",
|
|
phoneNumberVerified: true,
|
|
role: "ADMIN",
|
|
},
|
|
});
|
|
let FAAFU_ATOLL_ID = "";
|
|
const atollExists = await prisma.atoll.findFirst({
|
|
where: {
|
|
name: "F",
|
|
},
|
|
});
|
|
if (!atollExists) {
|
|
const NEW_ATOLL = await prisma.atoll.create({
|
|
data: {
|
|
name: "F",
|
|
},
|
|
});
|
|
FAAFU_ATOLL_ID = NEW_ATOLL.id;
|
|
|
|
const islands = DEFAULT_ISLANDS.map((name) => ({
|
|
name,
|
|
atollId: FAAFU_ATOLL_ID,
|
|
}));
|
|
await prisma.island.createMany({
|
|
data: islands,
|
|
});
|
|
}
|
|
}
|
|
|
|
main()
|
|
.then(() => prisma.$disconnect())
|
|
.catch(async (e) => {
|
|
console.error(e);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
});
|