FlowAPI / FlowAPI.Infrastructure /Migrations /20260517135820_Achievements.cs
danylokhodus's picture
init
b9c7f0e
Raw
History Blame Contribute Delete
3.54 kB
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FlowAPI.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class Achievements : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Achievements",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Title = table.Column<string>(type: "TEXT", maxLength: 200, nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
IconUrl = table.Column<string>(type: "TEXT", nullable: false),
Category = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false),
TargetValue = table.Column<int>(type: "INTEGER", nullable: false),
RewardPoints = table.Column<int>(type: "INTEGER", nullable: false),
TriggerEventName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Achievements", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserAchievements",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
AchievementId = table.Column<Guid>(type: "TEXT", nullable: false),
CurrentValue = table.Column<int>(type: "INTEGER", nullable: false),
IsUnlocked = table.Column<bool>(type: "INTEGER", nullable: false),
UnlockedAt = table.Column<DateTime>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserAchievements", x => x.Id);
table.ForeignKey(
name: "FK_UserAchievements_Achievements_AchievementId",
column: x => x.AchievementId,
principalTable: "Achievements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserAchievements_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_UserAchievements_AchievementId",
table: "UserAchievements",
column: "AchievementId");
migrationBuilder.CreateIndex(
name: "IX_UserAchievements_UserId",
table: "UserAchievements",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserAchievements");
migrationBuilder.DropTable(
name: "Achievements");
}
}
}