using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RR3CommunityServer.Migrations
{
///
public partial class AddMultiplayerSystem : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CompetitiveRatings",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserId = table.Column(type: "INTEGER", nullable: false),
Rating = table.Column(type: "INTEGER", nullable: false),
Wins = table.Column(type: "INTEGER", nullable: false),
Losses = table.Column(type: "INTEGER", nullable: false),
Draws = table.Column(type: "INTEGER", nullable: false),
Division = table.Column(type: "TEXT", nullable: false),
DivisionRank = table.Column(type: "INTEGER", nullable: false),
LastMatchAt = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CompetitiveRatings", x => x.Id);
table.ForeignKey(
name: "FK_CompetitiveRatings_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GhostData",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserId = table.Column(type: "INTEGER", nullable: false),
Track = table.Column(type: "TEXT", nullable: false),
CarId = table.Column(type: "TEXT", nullable: false),
RaceTime = table.Column(type: "REAL", nullable: false),
TelemetryData = table.Column(type: "TEXT", nullable: false),
UploadedAt = table.Column(type: "TEXT", nullable: false),
Downloads = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GhostData", x => x.Id);
table.ForeignKey(
name: "FK_GhostData_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RaceSessions",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
SessionCode = table.Column(type: "TEXT", nullable: false),
Track = table.Column(type: "TEXT", nullable: false),
CarClass = table.Column(type: "TEXT", nullable: false),
HostUserId = table.Column(type: "INTEGER", nullable: false),
MaxPlayers = table.Column(type: "INTEGER", nullable: false),
Status = table.Column(type: "TEXT", nullable: false),
IsPrivate = table.Column(type: "INTEGER", nullable: false),
CreatedAt = table.Column(type: "TEXT", nullable: false),
StartedAt = table.Column(type: "TEXT", nullable: true),
FinishedAt = table.Column(type: "TEXT", nullable: true),
HostId = table.Column(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RaceSessions", x => x.Id);
table.ForeignKey(
name: "FK_RaceSessions_Users_HostId",
column: x => x.HostId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "MatchmakingQueues",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserId = table.Column(type: "INTEGER", nullable: false),
CarClass = table.Column(type: "TEXT", nullable: false),
Track = table.Column(type: "TEXT", nullable: false),
GameMode = table.Column(type: "TEXT", nullable: false),
Status = table.Column(type: "TEXT", nullable: false),
QueuedAt = table.Column(type: "TEXT", nullable: false),
MatchedAt = table.Column(type: "TEXT", nullable: true),
SessionId = table.Column(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MatchmakingQueues", x => x.Id);
table.ForeignKey(
name: "FK_MatchmakingQueues_RaceSessions_SessionId",
column: x => x.SessionId,
principalTable: "RaceSessions",
principalColumn: "Id");
table.ForeignKey(
name: "FK_MatchmakingQueues_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RaceParticipants",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
SessionId = table.Column(type: "INTEGER", nullable: false),
UserId = table.Column(type: "INTEGER", nullable: false),
CarId = table.Column(type: "TEXT", nullable: false),
IsReady = table.Column(type: "INTEGER", nullable: false),
FinishPosition = table.Column(type: "INTEGER", nullable: true),
RaceTime = table.Column(type: "REAL", nullable: true),
RewardGold = table.Column(type: "INTEGER", nullable: true),
RewardCash = table.Column(type: "INTEGER", nullable: true),
RewardXP = table.Column(type: "INTEGER", nullable: true),
JoinedAt = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RaceParticipants", x => x.Id);
table.ForeignKey(
name: "FK_RaceParticipants_RaceSessions_SessionId",
column: x => x.SessionId,
principalTable: "RaceSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RaceParticipants_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 3, 3, 0, 53, 48, 427, DateTimeKind.Utc).AddTicks(9290), new DateTime(2026, 2, 24, 0, 53, 48, 427, DateTimeKind.Utc).AddTicks(9287) });
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 3, 3, 0, 53, 48, 427, DateTimeKind.Utc).AddTicks(9297), new DateTime(2026, 2, 24, 0, 53, 48, 427, DateTimeKind.Utc).AddTicks(9296) });
migrationBuilder.CreateIndex(
name: "IX_CompetitiveRatings_UserId",
table: "CompetitiveRatings",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_GhostData_UserId",
table: "GhostData",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_MatchmakingQueues_SessionId",
table: "MatchmakingQueues",
column: "SessionId");
migrationBuilder.CreateIndex(
name: "IX_MatchmakingQueues_UserId",
table: "MatchmakingQueues",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_RaceParticipants_SessionId",
table: "RaceParticipants",
column: "SessionId");
migrationBuilder.CreateIndex(
name: "IX_RaceParticipants_UserId",
table: "RaceParticipants",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_RaceSessions_HostId",
table: "RaceSessions",
column: "HostId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CompetitiveRatings");
migrationBuilder.DropTable(
name: "GhostData");
migrationBuilder.DropTable(
name: "MatchmakingQueues");
migrationBuilder.DropTable(
name: "RaceParticipants");
migrationBuilder.DropTable(
name: "RaceSessions");
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 3, 3, 0, 47, 32, 189, DateTimeKind.Utc).AddTicks(8910), new DateTime(2026, 2, 24, 0, 47, 32, 189, DateTimeKind.Utc).AddTicks(8907) });
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 3, 3, 0, 47, 32, 189, DateTimeKind.Utc).AddTicks(8918), new DateTime(2026, 2, 24, 0, 47, 32, 189, DateTimeKind.Utc).AddTicks(8918) });
}
}
}