Files
MinglarBackendNestJS/prisma/seed.ts

707 lines
38 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
// ✅ Countries
const india = await prisma.countries.upsert({
where: { countryName: 'India' },
update: {},
create: {
countryName: 'India',
countryCode: 'IN',
countryFlag: '🇮🇳',
isActive: true,
},
});
const usa = await prisma.countries.upsert({
where: { countryName: 'United States' },
update: {},
create: {
countryName: 'United States',
countryCode: 'US',
countryFlag: '🇺🇸',
isActive: true,
},
});
// ✅ Currencies
await prisma.currencies.createMany({
data: [
{ countryXid: india.id, currencyName: 'Indian Rupee', currencySymbol: '₹' },
{ countryXid: usa.id, currencyName: 'US Dollar', currencySymbol: '$' },
],
skipDuplicates: true,
});
// ✅ States
const maharashtra = await prisma.states.upsert({
where: { stateName: 'Maharashtra' },
update: {},
create: { countryXid: india.id, stateName: 'Maharashtra' },
});
const california = await prisma.states.upsert({
where: { stateName: 'California' },
update: {},
create: { countryXid: usa.id, stateName: 'California' },
});
// ✅ Cities
await prisma.cities.createMany({
data: [
{ stateXid: maharashtra.id, cityName: 'Mumbai' },
{ stateXid: california.id, cityName: 'Los Angeles' },
],
skipDuplicates: true,
});
// ✅ Taxes
await prisma.taxes.createMany({
data: [
{ countryXid: india.id, taxName: 'GST', taxPer: 18 },
{ countryXid: usa.id, taxName: 'VAT', taxPer: 10 },
],
skipDuplicates: true,
});
// ✅ Banks
const hdfc = await prisma.banks.upsert({
where: { bankName: 'HDFC Bank' },
update: {},
create: { countryXid: india.id, bankName: 'HDFC Bank' },
});
const chase = await prisma.banks.upsert({
where: { bankName: 'Chase Bank' },
update: {},
create: { countryXid: usa.id, bankName: 'Chase Bank' },
});
// ✅ Bank Branches
await prisma.bankBranches.createMany({
data: [
{
bankXid: hdfc.id,
stateXid: maharashtra.id,
cityXid: (await prisma.cities.findFirst({ where: { cityName: 'Mumbai' } }))!.id,
branchAddress: 'HDFC Fort Branch, Mumbai',
ifscCode: 'HDFC0001234',
},
{
bankXid: chase.id,
stateXid: california.id,
cityXid: (await prisma.cities.findFirst({ where: { cityName: 'Los Angeles' } }))!.id,
branchAddress: 'Chase Downtown LA',
ifscCode: 'CHASUS12345',
},
],
skipDuplicates: true,
});
// ✅ Interests + Activity Types
const chillandzen = await prisma.interests.upsert({
where: { interestName: 'Chill and Zen' },
update: {},
create: { interestName: 'Chill and Zen', displayOrder: 1 },
});
const sweatmode = await prisma.interests.upsert({
where: { interestName: 'Sweat Mode' },
update: {},
create: { interestName: 'Sweat Mode', displayOrder: 2 },
});
const gameon = await prisma.interests.upsert({
where: { interestName: 'Game On' },
update: {},
create: { interestName: 'Game On', displayOrder: 3 },
});
const partycentral = await prisma.interests.upsert({
where: { interestName: 'Party Central' },
update: {},
create: { interestName: 'Party Central', displayOrder: 4 },
});
const artsy = await prisma.interests.upsert({
where: { interestName: 'Artsy' },
update: {},
create: { interestName: 'Artsy', displayOrder: 5 },
});
const foodiediaries = await prisma.interests.upsert({
where: { interestName: 'Foodie Diaries' },
update: {},
create: { interestName: 'Foodie Diaries', displayOrder: 6 },
});
await prisma.activityTypes.createMany({
data: [
{ interestXid: chillandzen.id, activityTypeName: 'Cricket' },
{ interestXid: chillandzen.id, activityTypeName: 'Football' },
],
skipDuplicates: true,
});
// ✅ Document Types
await prisma.documentType.createMany({
data: [
{ documentTypeName: 'GST Certificate', displayOrder: 1 },
{ documentTypeName: 'PAN / BIN Card', displayOrder: 2 },
{ documentTypeName: 'Registration Certification', displayOrder: 3 },
{ documentTypeName: 'Aadhaar Card', displayOrder: 4 },
{ documentTypeName: 'Fire Insurance', displayOrder: 5 },
{ documentTypeName: 'ATOAI Certification', displayOrder: 6 },
{ documentTypeName: 'FASSI Certification', displayOrder: 7 },
{ documentTypeName: 'Safety Certification', displayOrder: 8 },
{ documentTypeName: 'Others', displayOrder: 9 },
],
skipDuplicates: true,
});
// ✅ Amenities
await prisma.amenities.createMany({
data: [
{ amenitiesName: 'Wi-Fi' },
{ amenitiesName: 'Air Conditioner' },
{ amenitiesName: 'Phone Charger' },
{ amenitiesName: 'Mobile Network' },
],
skipDuplicates: true, // prevents error if already seeded
});
// ✅ Food Types
await prisma.foodTypes.createMany({
data: [
{ foodTypeName: 'Veg' },
{ foodTypeName: 'Non-Veg' },
{ foodTypeName: 'Vegan' },
{ foodTypeName: 'Jain' },
],
skipDuplicates: true,
});
// ✅ AGE RESTRICTIONS
await prisma.ageRestrictions.createMany({
data: [
{ ageRestrictionName: 'Below 18', minAge: 1, maxAge: 17 },
{ ageRestrictionName: 'Above 18', minAge: 18, maxAge: 200 },
],
skipDuplicates: true,
});
// ✅ ALLOWED ENTRY TYPES
await prisma.allowedEntryTypes.createMany({
data: [
{ allowedEntryTypeName: 'Solo' },
{ allowedEntryTypeName: 'Couple' },
{ allowedEntryTypeName: 'Group' },
],
skipDuplicates: true,
});
// ✅ ROLES
await prisma.roles.createMany({
data: [
{ roleName: 'Admin' },
{ roleName: 'Co_Admin' },
{ roleName: 'Account_Manager' },
{ roleName: 'Host' },
{ roleName: 'Operator' },
{ roleName: 'User' },
],
skipDuplicates: true,
});
// ✅ Frequencies
await prisma.frequencies.createMany({
data: [
{ frequencyName: 'Single Event' },
{ frequencyName: 'Multiple Events Per Day' },
{ frequencyName: 'Training' },
],
skipDuplicates: true,
});
// ✅ Navigation Modes
await prisma.navigationModes.createMany({
data: [
{ navigationModeName: 'Elephant Ride', navigationModeIcon: '🚗' },
{ navigationModeName: 'Horse Ride', navigationModeIcon: '🏍️' },
{ navigationModeName: 'Camel Ride', navigationModeIcon: '🚶' },
],
skipDuplicates: true,
});
// ✅ Transport Modes
await prisma.transportModes.createMany({
data: [
{ transportModeName: 'Open Jeep / Car / SUV - 4 seater', transportModeIcon: '🚌' },
{ transportModeName: 'Open Jeep / Car / SUV - 6 seater', transportModeIcon: '🚌' },
{ transportModeName: '4W Jeep / SUV - 4 seater', transportModeIcon: '🚆' },
{ transportModeName: '4W Jeep / SUV - 6 seater', transportModeIcon: '🚆' },
],
skipDuplicates: true,
});
// ✅ PQQ Categories + Questions + Answers
// const PQQCategories = await prisma.pQQCategories.upsert({
// where: { categoryName: "Sustainability" },
// update: {},
// create: {
// categoryName: "Sustainability",
// displayOrder: 1,
// isActive: true,
// pqqsubCategories: {
// create: [
// // -----------------------------------------------------
// // SUBCATEGORY 1: Environmental Practices
// // -----------------------------------------------------
// {
// subCategoryName: "Environmental Practices",
// displayOrder: 1,
// isActive: true,
// questions: {
// create: [
// // QUESTION 1
// {
// questionName: 'What waste management practices do you have in place to minimize environmental impact? Examples: Recycling bins, composting organic waste, reducing single-use plastics.',
// maxPoints: 10,
// displayOrder: 1,
// PQQAnswers: {
// create: [
// { answerName: 'We do not have specific waste management practices.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We separate waste and recycle basic items like paper and plastic.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have a comprehensive recycling program including composting organic waste.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We actively reduce waste at the source and partner with local recycling organizations.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// // QUESTION 2
// {
// questionName: 'Can you provide examples of energy-efficient appliances or renewable energy sources you use? Examples: Solar panels, energy-efficient lighting, renewable energy certificates.',
// maxPoints: 10,
// displayOrder: 2,
// PQQAnswers: {
// create: [
// { answerName: 'We do not use energy-efficient appliances or renewable energy sources.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We use energy-efficient light bulbs and appliances.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have solar panels and energy-efficient heating/cooling systems.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We utilize a combination of renewable energy sources and advanced energy-saving technologies.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// {
// questionName: 'What measures do you take to conserve water? Examples: Low-flow fixtures, rainwater harvesting, greywater recycling.',
// maxPoints: 10,
// displayOrder: 3,
// PQQAnswers: {
// create: [
// { answerName: 'We do not have specific water conservation measures.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We encourage guests to limit water use.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have low-flow fixtures and water-saving appliances installed.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We implement rainwater harvesting and greywater recycling systems.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// {
// questionName: 'How do you monitor and reduce your carbon footprint? Examples: Carbon audits, offsetting emissions, energy-saving initiatives.',
// maxPoints: 10,
// displayOrder: 4,
// PQQAnswers: {
// create: [
// { answerName: 'We do not monitor or take steps to reduce our carbon footprint.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We track our energy usage and try to minimize it.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have set carbon reduction targets and regularly monitor our progress.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We offset our carbon emissions through verified programs and continually improve our sustainability practices.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// {
// questionName: 'Do you source products and materials sustainably? Can you provide examples? Examples: Local, organic, fair-trade products.',
// maxPoints: 10,
// displayOrder: 5,
// PQQAnswers: {
// create: [
// { answerName: 'We do not prioritize sustainable sourcing.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We source some products locally and sustainably.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We prioritize local, organic, and fair-trade products.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We have strict sourcing policies that ensure all products are sustainable and ethically produced.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// ]
// }
// },
// // -----------------------------------------------------
// // SUBCATEGORY 2: Community Impact
// // -----------------------------------------------------
// {
// subCategoryName: "Community Impact",
// displayOrder: 2,
// isActive: true,
// questions: {
// create: [
// // QUESTION 1
// {
// questionName:
// "How do you support local employment and engage with the community? Examples: Hiring local staff, partnering with community organizations, participating in local events.",
// maxPoints: 10,
// displayOrder: 1,
// PQQAnswers: {
// create: [
// { answerName: "We do not have specific practices to support local employment or community engagement.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We hire local staff but do not have formal community engagement programs.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We actively employ local residents and participate in community events.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We have partnerships with local organizations and invest in community development projects.", answerPoints: 10, displayOrder: 4 }
// ]
// }
// },
// // QUESTION 2
// {
// questionName:
// "Are you involved in any community projects or cultural preservation activities? Examples: Supporting local artisans, sponsoring cultural festivals, contributing to community development.",
// maxPoints: 10,
// displayOrder: 2,
// PQQAnswers: {
// create: [
// { answerName: "We are not involved in any community or cultural preservation projects.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We support community projects through donations.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We participate in and organize community events and cultural preservation activities.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We lead major community development initiatives and cultural preservation projects.", answerPoints: 10, displayOrder: 4 }
// ]
// }
// },
// // QUESTION 3
// {
// questionName:
// "Can you provide examples of how your business benefits the local community? Examples: Providing jobs, sourcing local products, investing in local infrastructure.",
// maxPoints: 10,
// displayOrder: 3,
// PQQAnswers: {
// create: [
// { answerName: "We do not have specific examples.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We provide employment opportunities for local residents.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We support local businesses by sourcing products and services locally.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We invest in local infrastructure and educational programs.", answerPoints: 10, displayOrder: 4 }
// ]
// }
// },
// ]
// }
// },
// // -----------------------------------------------------
// //SUBCATEGORY 3 : Sustainable Tourism Certification
// // -----------------------------------------------------
// {
// subCategoryName: "Sustainable Tourism Certification",
// displayOrder: 2,
// isActive: true,
// questions: {
// create: [
// // QUESTION 1
// {
// questionName:
// "Do you have any recognized sustainable tourism certifications (e.g., Green Globe, EarthCheck, Travelife)? Please provide details. Examples: Certification names and details, certificates.",
// maxPoints: 10,
// displayOrder: 1,
// PQQAnswers: {
// create: [
// { answerName: "We do not have any sustainable tourism certifications.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We are in the process of obtaining a certification.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We have one recognized sustainable tourism certification.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We hold multiple recognized sustainable tourism certifications and regularly audit our practices.", answerPoints: 10, displayOrder: 4 }
// { answerName: "Not applicable", answerPoints: 0, displayOrder: 5 }
// ]
// }
// }
// ]
// }
// },
// ]
// }
// },
// include: {
// pqqsubCategories: {
// include: {
// questions: {
// include: {
// PQQAnswers: true
// }
// }
// }
// }
// }
// });
const categoriesData = [
{
categoryName: "Sustainability",
displayOrder: 1,
isActive: true,
pqqsubCategories: {
create: [
// -----------------------------------------------------
// SUBCATEGORY 1: Environmental Practices
// -----------------------------------------------------
{
subCategoryName: "Environmental Practices",
displayOrder: 1,
isActive: true,
questions: {
create: [
// QUESTION 1
{
questionName: 'What waste management practices do you have in place to minimize environmental impact? Examples: Recycling bins, composting organic waste, reducing single-use plastics.',
maxPoints: 10,
displayOrder: 1,
PQQAnswers: {
create: [
{ answerName: 'We do not have specific waste management practices.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We separate waste and recycle basic items like paper and plastic.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have a comprehensive recycling program including composting organic waste.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We actively reduce waste at the source and partner with local recycling organizations.', answerPoints: 10, displayOrder: 4 },
],
},
},
// QUESTION 2
{
questionName: 'Can you provide examples of energy-efficient appliances or renewable energy sources you use? Examples: Solar panels, energy-efficient lighting, renewable energy certificates.',
maxPoints: 10,
displayOrder: 2,
PQQAnswers: {
create: [
{ answerName: 'We do not use energy-efficient appliances or renewable energy sources.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We use energy-efficient light bulbs and appliances.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have solar panels and energy-efficient heating/cooling systems.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We utilize a combination of renewable energy sources and advanced energy-saving technologies.', answerPoints: 10, displayOrder: 4 },
],
},
},
{
questionName: 'What measures do you take to conserve water? Examples: Low-flow fixtures, rainwater harvesting, greywater recycling.',
maxPoints: 10,
displayOrder: 3,
PQQAnswers: {
create: [
{ answerName: 'We do not have specific water conservation measures.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We encourage guests to limit water use.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have low-flow fixtures and water-saving appliances installed.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We implement rainwater harvesting and greywater recycling systems.', answerPoints: 10, displayOrder: 4 },
],
},
},
{
questionName: 'How do you monitor and reduce your carbon footprint? Examples: Carbon audits, offsetting emissions, energy-saving initiatives.',
maxPoints: 10,
displayOrder: 4,
PQQAnswers: {
create: [
{ answerName: 'We do not monitor or take steps to reduce our carbon footprint.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We track our energy usage and try to minimize it.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have set carbon reduction targets and regularly monitor our progress.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We offset our carbon emissions through verified programs and continually improve our sustainability practices.', answerPoints: 10, displayOrder: 4 },
],
},
},
{
questionName: 'Do you source products and materials sustainably? Can you provide examples? Examples: Local, organic, fair-trade products.',
maxPoints: 10,
displayOrder: 5,
PQQAnswers: {
create: [
{ answerName: 'We do not prioritize sustainable sourcing.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We source some products locally and sustainably.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We prioritize local, organic, and fair-trade products.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We have strict sourcing policies that ensure all products are sustainable and ethically produced.', answerPoints: 10, displayOrder: 4 },
],
},
},
]
}
},
// -----------------------------------------------------
// SUBCATEGORY 2: Community Impact
// -----------------------------------------------------
{
subCategoryName: "Community Impact",
displayOrder: 2,
isActive: true,
questions: {
create: [
// QUESTION 1
{
questionName:
"How do you support local employment and engage with the community? Examples: Hiring local staff, partnering with community organizations, participating in local events.",
maxPoints: 10,
displayOrder: 1,
PQQAnswers: {
create: [
{ answerName: "We do not have specific practices to support local employment or community engagement.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We hire local staff but do not have formal community engagement programs.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We actively employ local residents and participate in community events.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We have partnerships with local organizations and invest in community development projects.", answerPoints: 10, displayOrder: 4 }
]
}
},
// QUESTION 2
{
questionName:
"Are you involved in any community projects or cultural preservation activities? Examples: Supporting local artisans, sponsoring cultural festivals, contributing to community development.",
maxPoints: 10,
displayOrder: 2,
PQQAnswers: {
create: [
{ answerName: "We are not involved in any community or cultural preservation projects.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We support community projects through donations.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We participate in and organize community events and cultural preservation activities.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We lead major community development initiatives and cultural preservation projects.", answerPoints: 10, displayOrder: 4 }
]
}
},
// QUESTION 3
{
questionName:
"Can you provide examples of how your business benefits the local community? Examples: Providing jobs, sourcing local products, investing in local infrastructure.",
maxPoints: 10,
displayOrder: 3,
PQQAnswers: {
create: [
{ answerName: "We do not have specific examples.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We provide employment opportunities for local residents.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We support local businesses by sourcing products and services locally.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We invest in local infrastructure and educational programs.", answerPoints: 10, displayOrder: 4 }
]
}
},
]
}
},
// -----------------------------------------------------
//SUBCATEGORY 3 : Sustainable Tourism Certification
// -----------------------------------------------------
{
subCategoryName: "Sustainable Tourism Certification",
displayOrder: 2,
isActive: true,
questions: {
create: [
// QUESTION 1
{
questionName:
"Do you have any recognized sustainable tourism certifications (e.g., Green Globe, EarthCheck, Travelife)? Please provide details. Examples: Certification names and details, certificates.",
maxPoints: 10,
displayOrder: 1,
PQQAnswers: {
create: [
{ answerName: "We do not have any sustainable tourism certifications.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We are in the process of obtaining a certification.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We have one recognized sustainable tourism certification.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We hold multiple recognized sustainable tourism certifications and regularly audit our practices.", answerPoints: 10, displayOrder: 4 },
{ answerName: "Not applicable", answerPoints: 0, displayOrder: 5 }
]
}
}
]
}
},
]
}
},
// ----------------------------------------
// ADD MORE CATEGORIES HERE
// Example:
// ----------------------------------------
{
categoryName: "Safety",
displayOrder: 2,
subCategories: [
{
subCategoryName: "General Safety Protocols",
displayOrder: 1,
questions: [
{
questionName: "What safety measures do you have in place for your activities? Examples: Safety briefings, emergency exits, safety equipment.",
maxPoints: 10,
displayOrder: 1,
answers: [
{ name: "We do not have specific safety measures.", points: 0 },
{ name: "Basic fire extinguishers installed.", points: 5 },
{ name: "Full fire safety system installed.", points: 10 }
]
}
]
}
]
}
];
for (const category of categoriesData) {
await prisma.pQQCategories.upsert({
where: { categoryName: category.categoryName },
update: {},
create: {
categoryName: category.categoryName,
displayOrder: category.displayOrder,
isActive: true,
pqqsubCategories: {
create: category.subCategories.map((sub) => ({
subCategoryName: sub.subCategoryName,
displayOrder: sub.displayOrder,
isActive: true,
questions: {
create: sub.questions.map((q) => ({
questionName: q.questionName,
maxPoints: q.maxPoints,
displayOrder: q.displayOrder,
PQQAnswers: {
create: q.answers.map((ans, i) => ({
answerName: ans.name,
answerPoints: ans.points,
displayOrder: i + 1
}))
}
}))
}
}))
}
}
});
}
console.log('✅ Seed data inserted successfully!');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});