Skip to content

Commit f6c0a00

Browse files
committed
Add email address/domain migration
1 parent d5e5fd2 commit f6c0a00

2 files changed

Lines changed: 59 additions & 4 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Microsoft.EntityFrameworkCore.Infrastructure;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace Refresh.Database.Migrations
7+
{
8+
/// <inheritdoc />
9+
[DbContext(typeof(GameDatabaseContext))]
10+
[Migration("20260331143640_AddAbilityToDisallowEmailDomains")]
11+
public partial class AddAbilityToDisallowEmailDomains : Migration
12+
{
13+
/// <inheritdoc />
14+
protected override void Up(MigrationBuilder migrationBuilder)
15+
{
16+
migrationBuilder.RenameTable(name: "DisallowedEmails", newName: "DisallowedEmailAddresses");
17+
migrationBuilder.DropPrimaryKey(name: "PK_DisallowedEmails", table: "DisallowedEmailAddresses");
18+
migrationBuilder.RenameColumn(name: "Email", table: "DisallowedEmailAddresses", newName: "Address");
19+
migrationBuilder.AddPrimaryKey(name: "PK_DisallowedEmailAddresses", table: "DisallowedEmailAddresses", column: "Address");
20+
21+
migrationBuilder.CreateTable(
22+
name: "DisallowedEmailDomains",
23+
columns: table => new
24+
{
25+
Domain = table.Column<string>(type: "text", nullable: false)
26+
},
27+
constraints: table =>
28+
{
29+
table.PrimaryKey("PK_DisallowedEmailDomains", x => x.Domain);
30+
});
31+
}
32+
33+
/// <inheritdoc />
34+
protected override void Down(MigrationBuilder migrationBuilder)
35+
{
36+
migrationBuilder.DropTable(
37+
name: "DisallowedEmailDomains");
38+
39+
migrationBuilder.RenameTable(name: "DisallowedEmailAddresses", newName: "DisallowedEmails");
40+
migrationBuilder.DropPrimaryKey(name: "PK_DisallowedEmailAddresses", table: "DisallowedEmails");
41+
migrationBuilder.RenameColumn(name: "Address", table: "DisallowedEmails", newName: "Email");
42+
migrationBuilder.AddPrimaryKey(name: "PK_DisallowedEmails", table: "DisallowedEmails", column: "Email");
43+
}
44+
}
45+
}

Refresh.Database/Migrations/GameDatabaseContextModelSnapshot.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,14 +1510,24 @@ protected override void BuildModel(ModelBuilder modelBuilder)
15101510
b.ToTable("RequestStatistics");
15111511
});
15121512

1513-
modelBuilder.Entity("Refresh.Database.Models.Users.DisallowedEmail", b =>
1513+
modelBuilder.Entity("Refresh.Database.Models.Users.DisallowedEmailAddress", b =>
15141514
{
1515-
b.Property<string>("Email")
1515+
b.Property<string>("Address")
15161516
.HasColumnType("text");
15171517

1518-
b.HasKey("Email");
1518+
b.HasKey("Address");
15191519

1520-
b.ToTable("DisallowedEmails");
1520+
b.ToTable("DisallowedEmailAddresses");
1521+
});
1522+
1523+
modelBuilder.Entity("Refresh.Database.Models.Users.DisallowedEmailDomain", b =>
1524+
{
1525+
b.Property<string>("Domain")
1526+
.HasColumnType("text");
1527+
1528+
b.HasKey("Domain");
1529+
1530+
b.ToTable("DisallowedEmailDomains");
15211531
});
15221532

15231533
modelBuilder.Entity("Refresh.Database.Models.Users.DisallowedUser", b =>

0 commit comments

Comments
 (0)