192 lines
5.8 KiB
TypeScript
192 lines
5.8 KiB
TypeScript
|
|
import { PrismaClient } from '@prisma/client';
|
|||
|
|
|
|||
|
|
const prisma = new PrismaClient();
|
|||
|
|
|
|||
|
|
async function main() {
|
|||
|
|
console.log('Starting seed...');
|
|||
|
|
|
|||
|
|
// Create demo user
|
|||
|
|
const demoUser = await prisma.user.upsert({
|
|||
|
|
where: { email: 'demo@100k1.ru' },
|
|||
|
|
update: {},
|
|||
|
|
create: {
|
|||
|
|
email: 'demo@100k1.ru',
|
|||
|
|
name: 'Демо пользователь',
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.log('Demo user created:', demoUser);
|
|||
|
|
|
|||
|
|
// Demo questions data
|
|||
|
|
const demoQuestions = [
|
|||
|
|
{
|
|||
|
|
text: 'Что дед мороз делает летом?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Отдыхает', points: 100 },
|
|||
|
|
{ text: 'Готовит подарки', points: 80 },
|
|||
|
|
{ text: 'Спит', points: 60 },
|
|||
|
|
{ text: 'Путешествует', points: 40 },
|
|||
|
|
{ text: 'Загорает', points: 20 },
|
|||
|
|
{ text: 'Работает', points: 10 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Что намазывают на хлеб?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Масло', points: 100 },
|
|||
|
|
{ text: 'Икру', points: 80 },
|
|||
|
|
{ text: 'Варенье', points: 60 },
|
|||
|
|
{ text: 'Паштет', points: 40 },
|
|||
|
|
{ text: 'Майонез', points: 20 },
|
|||
|
|
{ text: 'Горчицу', points: 10 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Кто работает в новый год?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Дед Мороз', points: 100 },
|
|||
|
|
{ text: 'Снегурочка', points: 80 },
|
|||
|
|
{ text: 'Врач', points: 60 },
|
|||
|
|
{ text: 'Полицейский', points: 40 },
|
|||
|
|
{ text: 'Таксист', points: 20 },
|
|||
|
|
{ text: 'Продавец', points: 10 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Почему лошадь не курит?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Боится умереть', points: 100 },
|
|||
|
|
{ text: 'Неудобно (копыта мешают)', points: 80 },
|
|||
|
|
{ text: 'Не хочет', points: 60 },
|
|||
|
|
{ text: 'Не продают', points: 40 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Какая самая "лошадиная" фамилия?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Конев', points: 100 },
|
|||
|
|
{ text: 'Жеребцов', points: 80 },
|
|||
|
|
{ text: 'Кобылин', points: 60 },
|
|||
|
|
{ text: 'Табунов', points: 40 },
|
|||
|
|
{ text: 'Лошадкин', points: 20 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Что носят на голове?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Шапка', points: 100 },
|
|||
|
|
{ text: 'Шляпа', points: 80 },
|
|||
|
|
{ text: 'Кепка', points: 60 },
|
|||
|
|
{ text: 'Корона', points: 40 },
|
|||
|
|
{ text: 'Платок', points: 20 },
|
|||
|
|
{ text: 'Панама', points: 10 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Что можно найти в холодильнике?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Еда', points: 100 },
|
|||
|
|
{ text: 'Молоко', points: 80 },
|
|||
|
|
{ text: 'Колбаса', points: 60 },
|
|||
|
|
{ text: 'Масло', points: 40 },
|
|||
|
|
{ text: 'Лёд', points: 20 },
|
|||
|
|
{ text: 'Свет', points: 10 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Где можно встретить новый год?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Дома', points: 100 },
|
|||
|
|
{ text: 'На улице', points: 80 },
|
|||
|
|
{ text: 'В кафе', points: 60 },
|
|||
|
|
{ text: 'У друзей', points: 40 },
|
|||
|
|
{ text: 'На работе', points: 20 },
|
|||
|
|
{ text: 'В самолёте', points: 10 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
// Create question pack
|
|||
|
|
const questionPack = await prisma.questionPack.upsert({
|
|||
|
|
where: { id: 'demo-pack-1' },
|
|||
|
|
update: {},
|
|||
|
|
create: {
|
|||
|
|
id: 'demo-pack-1',
|
|||
|
|
name: 'Демо пак вопросов',
|
|||
|
|
description: 'Базовый набор вопросов для игры "100 к 1"',
|
|||
|
|
category: 'Общие',
|
|||
|
|
isPublic: true,
|
|||
|
|
createdBy: demoUser.id,
|
|||
|
|
questions: demoQuestions,
|
|||
|
|
questionCount: demoQuestions.length,
|
|||
|
|
rating: 5.0,
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.log('Question pack created:', questionPack);
|
|||
|
|
|
|||
|
|
// Create family questions pack
|
|||
|
|
const familyQuestions = [
|
|||
|
|
{
|
|||
|
|
text: 'Что мама говорит чаще всего?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Убери', points: 100 },
|
|||
|
|
{ text: 'Поешь', points: 80 },
|
|||
|
|
{ text: 'Спать', points: 60 },
|
|||
|
|
{ text: 'Я люблю тебя', points: 40 },
|
|||
|
|
{ text: 'Делай уроки', points: 20 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Что папа делает на выходных?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Отдыхает', points: 100 },
|
|||
|
|
{ text: 'Чинит что-то', points: 80 },
|
|||
|
|
{ text: 'Смотрит телевизор', points: 60 },
|
|||
|
|
{ text: 'Спит', points: 40 },
|
|||
|
|
{ text: 'Работает', points: 20 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
text: 'Что бабушка любит дарить внукам?',
|
|||
|
|
answers: [
|
|||
|
|
{ text: 'Деньги', points: 100 },
|
|||
|
|
{ text: 'Еду', points: 80 },
|
|||
|
|
{ text: 'Одежду', points: 60 },
|
|||
|
|
{ text: 'Игрушки', points: 40 },
|
|||
|
|
{ text: 'Конфеты', points: 20 },
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
const familyPack = await prisma.questionPack.upsert({
|
|||
|
|
where: { id: 'family-pack-1' },
|
|||
|
|
update: {},
|
|||
|
|
create: {
|
|||
|
|
id: 'family-pack-1',
|
|||
|
|
name: 'Семейные вопросы',
|
|||
|
|
description: 'Вопросы для семейной игры',
|
|||
|
|
category: 'Семья',
|
|||
|
|
isPublic: true,
|
|||
|
|
createdBy: demoUser.id,
|
|||
|
|
questions: familyQuestions,
|
|||
|
|
questionCount: familyQuestions.length,
|
|||
|
|
rating: 4.8,
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.log('Family pack created:', familyPack);
|
|||
|
|
|
|||
|
|
console.log('Seed completed successfully!');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
main()
|
|||
|
|
.then(async () => {
|
|||
|
|
await prisma.$disconnect();
|
|||
|
|
})
|
|||
|
|
.catch(async (e) => {
|
|||
|
|
console.error('Seed error:', e);
|
|||
|
|
await prisma.$disconnect();
|
|||
|
|
process.exit(1);
|
|||
|
|
});
|