Files
Sharpbin/SharpbinV3.Server/Migrations/20260618231408_uniqueEmails.cs
T
whoswhip d4976ac9aa feat: password resets
fix: frontend docker file
chore: format via csharpier again
2026-06-18 21:15:34 -04:00

46 lines
1.2 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SharpbinV3.Server.Migrations
{
/// <inheritdoc />
public partial class uniqueEmails : Migration
{
/// <inheritdoc />
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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Users_Email",
table: "Users");
}
}
}