Files
UniVerse/backend/UniVerse.Infrastructure/Migrations/20260512120000_SeedAchievements.cs
serega404 feff77b232
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 10s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m53s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 28s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 7s
feat: добавил каталог достижений и автоначисление
Реализовал автосоздание и обновление каталога достижений на бэке и синхронизацию на фронте.
2026-05-12 23:21:39 +03:00

71 lines
5.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using UniVerse.Infrastructure.Data;
#nullable disable
namespace UniVerse.Infrastructure.Migrations
{
/// <inheritdoc />
[DbContext(typeof(AppDbContext))]
[Migration("20260512120000_SeedAchievements")]
public partial class SeedAchievements : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("""
UPDATE achievements
SET condition = CASE condition
WHEN 'reviews_1' THEN 'reviews_written:1'
WHEN 'reviews_5' THEN 'reviews_written:5'
WHEN 'reviews_10' THEN 'reviews_written:10'
WHEN 'attended_5' THEN 'lectures_attended:5'
WHEN 'attended_10' THEN 'lectures_attended:10'
ELSE condition
END
WHERE condition IN ('reviews_1', 'reviews_5', 'reviews_10', 'attended_5', 'attended_10');
""");
migrationBuilder.Sql("""
INSERT INTO achievements (id, name, description, icon_url, xp_reward, coin_reward, condition, created_at)
VALUES
(1001, 'Добро пожаловать в UniVerse', 'Совершить первое действие: записаться на лекцию, оставить отзыв или посетить занятие.', 'sparkles', 0, 10, 'first_activity:1', NOW()),
(1002, 'Первый шаг', 'Посетить первую открытую лекцию.', 'book-2', 0, 10, 'lectures_attended:1', NOW()),
(1003, 'Вошел во вкус', 'Посетить 3 открытые лекции.', 'books', 0, 20, 'lectures_attended:3', NOW()),
(1004, 'Постоянный слушатель', 'Посетить 5 открытых лекций.', 'calendar-event', 0, 35, 'lectures_attended:5', NOW()),
(1005, 'Академический марафон', 'Посетить 10 открытых лекций.', 'stopwatch', 0, 60, 'lectures_attended:10', NOW()),
(1006, 'Грандмастер лекций', 'Посетить 25 открытых лекций.', 'trophy', 0, 120, 'lectures_attended:25', NOW()),
(1007, 'Первый отзыв', 'Оставить первый отзыв о посещенной лекции.', 'message-circle', 0, 10, 'reviews_written:1', NOW()),
(1008, 'Голос аудитории', 'Оставить 3 отзыва о лекциях.', 'thumb-up', 0, 25, 'reviews_written:3', NOW()),
(1009, 'Рецензент', 'Оставить 10 отзывов о лекциях.', 'clipboard-list', 0, 70, 'reviews_written:10', NOW()),
(1010, 'Голос перемен', 'Оставить 25 отзывов о лекциях.', 'chart-line', 0, 150, 'reviews_written:25', NOW()),
(1011, 'Смелый выбор', 'Записаться на первую открытую лекцию.', 'calendar', 0, 5, 'lectures_registered:1', NOW()),
(1012, 'План на неделю', 'Иметь 3 активные записи на будущие лекции.', 'calendar-event', 0, 15, 'active_registrations:3', NOW()),
(1013, 'Полный календарь', 'Иметь 5 активных записей на будущие лекции.', 'alarm', 0, 30, 'active_registrations:5', NOW()),
(1014, 'Серия интереса', 'Посещать открытые лекции 3 недели подряд.', 'star', 0, 50, 'attendance_streak_weeks:3', NOW()),
(1015, 'Учебный месяц', 'Посещать открытые лекции 4 недели подряд.', 'sparkles', 0, 80, 'attendance_streak_weeks:4', NOW()),
(1016, 'Без пропусков', 'Посетить 5 лекций, на которые была оформлена запись.', 'circle-check', 0, 40, 'attended_registered:5', NOW()),
(1017, 'Надежный участник', 'Посетить 10 лекций, на которые была оформлена запись.', 'shield', 0, 75, 'attended_registered:10', NOW()),
(1018, 'Капитал знаний', 'Получить 500 монет за активность на платформе.', 'coin', 0, 80, 'coins_earned:500', NOW()),
(1019, 'Новый уровень', 'Достигнуть 2 уровня.', 'star', 0, 25, 'level_reached:2', NOW()),
(1020, 'Уверенный рост', 'Достигнуть 5 уровня.', 'chart-bar', 0, 100, 'level_reached:5', NOW()),
(1021, 'Профиль заполнен', 'Заполнить имя и аватар в профиле.', 'user', 0, 10, 'profile_completed:1', NOW())
ON CONFLICT (id) DO UPDATE
SET name = EXCLUDED.name,
description = EXCLUDED.description,
icon_url = EXCLUDED.icon_url,
xp_reward = EXCLUDED.xp_reward,
coin_reward = EXCLUDED.coin_reward,
condition = EXCLUDED.condition;
""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM achievements WHERE id BETWEEN 1001 AND 1021;");
}
}
}