Fix database model migrations after role bans.

Role bans (#6703) seemed to have changes to the DB model from after the migrations were created. This means a bunch of constraints/indices changed names and this wasn't reflected in a migration yet.
This commit is contained in:
Pieter-Jan Briers
2022-03-08 23:36:02 +01:00
parent 58242e9652
commit 6b66c7db8a
6 changed files with 2279 additions and 42 deletions

View File

@@ -685,10 +685,6 @@ namespace Content.Server.Database.Migrations.Postgres
.HasColumnType("text")
.HasColumnName("role_id");
b.Property<int?>("UnbanId")
.HasColumnType("integer")
.HasColumnName("unban_id");
b.Property<Guid?>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
@@ -696,12 +692,15 @@ namespace Content.Server.Database.Migrations.Postgres
b.HasKey("Id")
.HasName("PK_server_role_ban");
b.HasIndex("UnbanId")
.HasDatabaseName("IX_server_role_ban__unban_id");
b.HasIndex("Address");
b.HasIndex("UserId");
b.ToTable("server_role_ban", (string)null);
b.HasCheckConstraint("AddressNotIPv6MappedIPv4", "NOT inet '::ffff:0.0.0.0/96' >>= address");
b.HasCheckConstraint("HaveEitherAddressOrUserIdOrHWId", "address IS NOT NULL OR user_id IS NOT NULL OR hwid IS NOT NULL");
});
modelBuilder.Entity("Content.Server.Database.ServerRoleUnban", b =>
@@ -729,7 +728,7 @@ namespace Content.Server.Database.Migrations.Postgres
.HasName("PK_server_role_unban");
b.HasIndex("BanId")
.HasDatabaseName("IX_server_role_unban_ban_id");
.IsUnique();
b.ToTable("server_role_unban", (string)null);
});
@@ -930,24 +929,14 @@ namespace Content.Server.Database.Migrations.Postgres
b.Navigation("Connection");
});
modelBuilder.Entity("Content.Server.Database.ServerRoleBan", b =>
{
b.HasOne("Content.Server.Database.ServerRoleUnban", "Unban")
.WithMany()
.HasForeignKey("UnbanId")
.HasConstraintName("FK_server_role_ban_server_role_unban__unban_id");
b.Navigation("Unban");
});
modelBuilder.Entity("Content.Server.Database.ServerRoleUnban", b =>
{
b.HasOne("Content.Server.Database.ServerBan", "Ban")
.WithMany()
.HasForeignKey("BanId")
b.HasOne("Content.Server.Database.ServerRoleBan", "Ban")
.WithOne("Unban")
.HasForeignKey("Content.Server.Database.ServerRoleUnban", "BanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("FK_server_role_unban_server_ban_ban_id");
.HasConstraintName("FK_server_role_unban_server_role_ban_ban_id");
b.Navigation("Ban");
});
@@ -1033,6 +1022,11 @@ namespace Content.Server.Database.Migrations.Postgres
b.Navigation("Unban");
});
modelBuilder.Entity("Content.Server.Database.ServerRoleBan", b =>
{
b.Navigation("Unban");
});
#pragma warning restore 612, 618
}
}