using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SharpbinV3.Server.Migrations { /// public partial class uniqueEmails : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql( """ UPDATE "Users" SET "Email" = NULL, "EmailVerified" = 0 WHERE "Email" IS NULL OR trim("Email") = ''; """ ); migrationBuilder.Sql( """ UPDATE "Users" SET "Email" = lower(trim("Email")) WHERE "Email" IS NOT NULL; """ ); migrationBuilder.CreateIndex( name: "IX_Users_Email", table: "Users", column: "Email", unique: true, filter: "\"Email\" IS NOT NULL"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropIndex( name: "IX_Users_Email", table: "Users"); } } }