using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FlowAPI.Infrastructure.Migrations { /// public partial class Achievements : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Achievements", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Title = table.Column(type: "TEXT", maxLength: 200, nullable: false), Description = table.Column(type: "TEXT", nullable: false), IconUrl = table.Column(type: "TEXT", nullable: false), Category = table.Column(type: "TEXT", maxLength: 100, nullable: false), Type = table.Column(type: "INTEGER", nullable: false), TargetValue = table.Column(type: "INTEGER", nullable: false), RewardPoints = table.Column(type: "INTEGER", nullable: false), TriggerEventName = table.Column(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(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), AchievementId = table.Column(type: "TEXT", nullable: false), CurrentValue = table.Column(type: "INTEGER", nullable: false), IsUnlocked = table.Column(type: "INTEGER", nullable: false), UnlockedAt = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "UserAchievements"); migrationBuilder.DropTable( name: "Achievements"); } } }