mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
46 lines
1.2 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|