using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FindAndDrive.Persistence.Migrations { public partial class ChancesOfApprovalEnum : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("SELECT * INTO #tt1 FROM ApplicantPredicition"); migrationBuilder.AlterColumn( name: "ChancesOfApproval", table: "ApplicantPredicition", type: "nvarchar(10)", maxLength: 10, nullable: false, oldClrType: typeof(int), oldType: "int"); migrationBuilder.Sql("UPDATE tn SET tn.ChancesOfApproval = CASE\r\n WHEN tt.ChancesOfApproval = 0 THEN 'Low'\r\n\tWHEN tt.ChancesOfApproval = 1 THEN 'Medium'\r\n\tWHEN tt.ChancesOfApproval = 2 THEN 'High'\r\n\tWHEN tt.ChancesOfApproval = 3 THEN 'Undetermined'\r\nEND\r\nFROM ApplicantPredicition tn\r\nLEFT JOIN #tt1 tt ON tn.ApplicantPredictionId = tt.ApplicantPredictionId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.AlterColumn( name: "ChancesOfApproval", table: "ApplicantPredicition", type: "int", nullable: false, oldClrType: typeof(string), oldType: "nvarchar(10)", oldMaxLength: 10); } } }