using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace RR3CommunityServer.Migrations
{
    /// <inheritdoc />
    public partial class AddLeaderboardsAndRecords : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "LeaderboardEntries",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    SynergyId = table.Column<string>(type: "TEXT", nullable: false),
                    PlayerName = table.Column<string>(type: "TEXT", nullable: false),
                    RecordType = table.Column<string>(type: "TEXT", nullable: false),
                    RecordCategory = table.Column<string>(type: "TEXT", nullable: false),
                    TrackName = table.Column<string>(type: "TEXT", nullable: true),
                    CarName = table.Column<string>(type: "TEXT", nullable: true),
                    TimeSeconds = table.Column<double>(type: "REAL", nullable: false),
                    SubmittedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LeaderboardEntries", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PersonalRecords",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    SynergyId = table.Column<string>(type: "TEXT", nullable: false),
                    RecordType = table.Column<string>(type: "TEXT", nullable: false),
                    RecordCategory = table.Column<string>(type: "TEXT", nullable: false),
                    TrackName = table.Column<string>(type: "TEXT", nullable: true),
                    CarName = table.Column<string>(type: "TEXT", nullable: true),
                    BestTimeSeconds = table.Column<double>(type: "REAL", nullable: false),
                    AchievedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
                    PreviousBestTime = table.Column<DateTime>(type: "TEXT", nullable: true),
                    ImprovementSeconds = table.Column<double>(type: "REAL", nullable: true),
                    TotalAttempts = table.Column<int>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PersonalRecords", x => x.Id);
                });

            migrationBuilder.UpdateData(
                table: "TimeTrials",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "EndDate", "StartDate" },
                values: new object[] { new DateTime(2026, 3, 2, 1, 33, 39, 587, DateTimeKind.Utc).AddTicks(7946), new DateTime(2026, 2, 23, 1, 33, 39, 587, DateTimeKind.Utc).AddTicks(7944) });

            migrationBuilder.UpdateData(
                table: "TimeTrials",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "EndDate", "StartDate" },
                values: new object[] { new DateTime(2026, 3, 2, 1, 33, 39, 587, DateTimeKind.Utc).AddTicks(7954), new DateTime(2026, 2, 23, 1, 33, 39, 587, DateTimeKind.Utc).AddTicks(7954) });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "LeaderboardEntries");

            migrationBuilder.DropTable(
                name: "PersonalRecords");

            migrationBuilder.UpdateData(
                table: "TimeTrials",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "EndDate", "StartDate" },
                values: new object[] { new DateTime(2026, 3, 1, 7, 47, 46, 836, DateTimeKind.Utc).AddTicks(7182), new DateTime(2026, 2, 22, 7, 47, 46, 836, DateTimeKind.Utc).AddTicks(7180) });

            migrationBuilder.UpdateData(
                table: "TimeTrials",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "EndDate", "StartDate" },
                values: new object[] { new DateTime(2026, 3, 1, 7, 47, 46, 836, DateTimeKind.Utc).AddTicks(7192), new DateTime(2026, 2, 22, 7, 47, 46, 836, DateTimeKind.Utc).AddTicks(7191) });
        }
    }
}
