Remove autogenerated from admin log key. (#18377)

This commit is contained in:
Pieter-Jan Briers
2023-07-29 08:44:28 +02:00
committed by GitHub
parent 253136b0b6
commit 7c9d7423d2
7 changed files with 3525 additions and 7 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Content.Server.Database.Migrations.Postgres
{
/// <inheritdoc />
public partial class AdminLogCompoundKey : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "admin_log_id",
table: "admin_log",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "admin_log_id",
table: "admin_log",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
}
}
}

View File

@@ -85,12 +85,9 @@ namespace Content.Server.Database.Migrations.Postgres
modelBuilder.Entity("Content.Server.Database.AdminLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("admin_log_id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("RoundId")
.HasColumnType("integer")
.HasColumnName("round_id");

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Content.Server.Database.Migrations.Sqlite
{
/// <inheritdoc />
public partial class AdminLogCompoundKey : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -76,7 +76,6 @@ namespace Content.Server.Database.Migrations.Sqlite
modelBuilder.Entity("Content.Server.Database.AdminLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("admin_log_id");

View File

@@ -96,8 +96,7 @@ namespace Content.Server.Database
.HasKey(log => new {log.Id, log.RoundId});
modelBuilder.Entity<AdminLog>()
.Property(log => log.Id)
.ValueGeneratedOnAdd();
.Property(log => log.Id);
modelBuilder.Entity<AdminLog>()
.HasIndex(log => log.Date);
@@ -491,7 +490,7 @@ namespace Content.Server.Database
[Index(nameof(Type))]
public class AdminLog
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Key]
public int Id { get; set; }
[Key, ForeignKey("Round")] public int RoundId { get; set; }