Store round start date in the database (#21153)
This commit is contained in:
1775
Content.Server.Database/Migrations/Postgres/20231021071411_RoundStartDate.Designer.cs
generated
Normal file
1775
Content.Server.Database/Migrations/Postgres/20231021071411_RoundStartDate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
|||||||
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Content.Server.Database.Migrations.Postgres
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class RoundStartDate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "start_date",
|
||||||
|
table: "round",
|
||||||
|
type: "timestamp with time zone",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_round_start_date",
|
||||||
|
table: "round",
|
||||||
|
column: "start_date");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_round_start_date",
|
||||||
|
table: "round");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "start_date",
|
||||||
|
table: "round");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -856,12 +856,20 @@ namespace Content.Server.Database.Migrations.Postgres
|
|||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("server_id");
|
.HasColumnName("server_id");
|
||||||
|
|
||||||
|
b.Property<DateTime>("StartDate")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValue(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified))
|
||||||
|
.HasColumnName("start_date");
|
||||||
|
|
||||||
b.HasKey("Id")
|
b.HasKey("Id")
|
||||||
.HasName("PK_round");
|
.HasName("PK_round");
|
||||||
|
|
||||||
b.HasIndex("ServerId")
|
b.HasIndex("ServerId")
|
||||||
.HasDatabaseName("IX_round_server_id");
|
.HasDatabaseName("IX_round_server_id");
|
||||||
|
|
||||||
|
b.HasIndex("StartDate");
|
||||||
|
|
||||||
b.ToTable("round", (string)null);
|
b.ToTable("round", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
1705
Content.Server.Database/Migrations/Sqlite/20231021071407_RoundStartDate.Designer.cs
generated
Normal file
1705
Content.Server.Database/Migrations/Sqlite/20231021071407_RoundStartDate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
|||||||
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Content.Server.Database.Migrations.Sqlite
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class RoundStartDate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "start_date",
|
||||||
|
table: "round",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_round_start_date",
|
||||||
|
table: "round",
|
||||||
|
column: "start_date");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_round_start_date",
|
||||||
|
table: "round");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "start_date",
|
||||||
|
table: "round");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -806,12 +806,20 @@ namespace Content.Server.Database.Migrations.Sqlite
|
|||||||
.HasColumnType("INTEGER")
|
.HasColumnType("INTEGER")
|
||||||
.HasColumnName("server_id");
|
.HasColumnName("server_id");
|
||||||
|
|
||||||
|
b.Property<DateTime>("StartDate")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT")
|
||||||
|
.HasDefaultValue(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified))
|
||||||
|
.HasColumnName("start_date");
|
||||||
|
|
||||||
b.HasKey("Id")
|
b.HasKey("Id")
|
||||||
.HasName("PK_round");
|
.HasName("PK_round");
|
||||||
|
|
||||||
b.HasIndex("ServerId")
|
b.HasIndex("ServerId")
|
||||||
.HasDatabaseName("IX_round_server_id");
|
.HasDatabaseName("IX_round_server_id");
|
||||||
|
|
||||||
|
b.HasIndex("StartDate");
|
||||||
|
|
||||||
b.ToTable("round", (string)null);
|
b.ToTable("round", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ namespace Content.Server.Database
|
|||||||
.HasForeignKey(player => player.PlayerUserId)
|
.HasForeignKey(player => player.PlayerUserId)
|
||||||
.HasPrincipalKey(player => player.UserId);
|
.HasPrincipalKey(player => player.UserId);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Round>()
|
||||||
|
.HasIndex(round => round.StartDate);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Round>()
|
||||||
|
.Property(round => round.StartDate)
|
||||||
|
.HasDefaultValue(default(DateTime));
|
||||||
|
|
||||||
modelBuilder.Entity<AdminLogPlayer>()
|
modelBuilder.Entity<AdminLogPlayer>()
|
||||||
.HasKey(logPlayer => new {logPlayer.PlayerUserId, logPlayer.LogId, logPlayer.RoundId});
|
.HasKey(logPlayer => new {logPlayer.PlayerUserId, logPlayer.LogId, logPlayer.RoundId});
|
||||||
|
|
||||||
@@ -468,6 +475,8 @@ namespace Content.Server.Database
|
|||||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
|
||||||
public List<Player> Players { get; set; } = default!;
|
public List<Player> Players { get; set; } = default!;
|
||||||
|
|
||||||
public List<AdminLog> AdminLogs { get; set; } = default!;
|
public List<AdminLog> AdminLogs { get; set; } = default!;
|
||||||
|
|||||||
@@ -677,6 +677,7 @@ namespace Content.Server.Database
|
|||||||
|
|
||||||
var round = new Round
|
var round = new Round
|
||||||
{
|
{
|
||||||
|
StartDate = DateTime.UtcNow,
|
||||||
Players = players,
|
Players = players,
|
||||||
ServerId = server.Id
|
ServerId = server.Id
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user