using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace ShadowedRealms.Data.Migrations
{
    /// <inheritdoc />
    public partial class FixEFCoreWarnings : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Kingdoms",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    Number = table.Column<int>(type: "integer", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
                    IsActive = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
                    MaxPopulation = table.Column<int>(type: "integer", nullable: false, defaultValue: 1500),
                    CurrentPopulation = table.Column<int>(type: "integer", nullable: false, defaultValue: 0),
                    TotalPower = table.Column<long>(type: "bigint", nullable: false),
                    LastKvKDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    KvKWins = table.Column<int>(type: "integer", nullable: false),
                    KvKLosses = table.Column<int>(type: "integer", nullable: false),
                    KvKDraws = table.Column<int>(type: "integer", nullable: false),
                    IsEligibleForKvK = table.Column<bool>(type: "boolean", nullable: false),
                    AcceptingNewPlayers = table.Column<bool>(type: "boolean", nullable: false),
                    MergerAvailableDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    IsEligibleForMerger = table.Column<bool>(type: "boolean", nullable: false),
                    Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
                    WelcomeMessage = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
                    AutoKickInactivePlayers = table.Column<bool>(type: "boolean", nullable: false),
                    InactivityKickDays = table.Column<int>(type: "integer", nullable: false),
                    EnableTaxSystem = table.Column<bool>(type: "boolean", nullable: false),
                    TaxRate = table.Column<decimal>(type: "numeric(5,4)", nullable: false),
                    LastActivity = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    TotalTaxCollected = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    IsInKvK = table.Column<bool>(type: "boolean", nullable: false),
                    KvKHostAllianceId = table.Column<int>(type: "integer", nullable: true),
                    CurrentPowerRank = table.Column<int>(type: "integer", nullable: false),
                    KingdomId = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Kingdoms", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Players_Auth",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    PlayerId = table.Column<int>(type: "integer", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    LastLoginAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
                    NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
                    Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
                    NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
                    EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
                    PasswordHash = table.Column<string>(type: "text", nullable: true),
                    SecurityStamp = table.Column<string>(type: "text", nullable: true),
                    ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
                    PhoneNumber = table.Column<string>(type: "text", nullable: true),
                    PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
                    TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
                    LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
                    LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
                    AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Players_Auth", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Roles",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
                    NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
                    ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Roles", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Player_Claims",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    UserId = table.Column<int>(type: "integer", nullable: false),
                    ClaimType = table.Column<string>(type: "text", nullable: true),
                    ClaimValue = table.Column<string>(type: "text", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Player_Claims", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Player_Claims_Players_Auth_UserId",
                        column: x => x.UserId,
                        principalTable: "Players_Auth",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Player_Logins",
                columns: table => new
                {
                    LoginProvider = table.Column<string>(type: "text", nullable: false),
                    ProviderKey = table.Column<string>(type: "text", nullable: false),
                    ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
                    UserId = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Player_Logins", x => new { x.LoginProvider, x.ProviderKey });
                    table.ForeignKey(
                        name: "FK_Player_Logins_Players_Auth_UserId",
                        column: x => x.UserId,
                        principalTable: "Players_Auth",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Player_Tokens",
                columns: table => new
                {
                    UserId = table.Column<int>(type: "integer", nullable: false),
                    LoginProvider = table.Column<string>(type: "text", nullable: false),
                    Name = table.Column<string>(type: "text", nullable: false),
                    Value = table.Column<string>(type: "text", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Player_Tokens", x => new { x.UserId, x.LoginProvider, x.Name });
                    table.ForeignKey(
                        name: "FK_Player_Tokens_Players_Auth_UserId",
                        column: x => x.UserId,
                        principalTable: "Players_Auth",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Player_Roles",
                columns: table => new
                {
                    UserId = table.Column<int>(type: "integer", nullable: false),
                    RoleId = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Player_Roles", x => new { x.UserId, x.RoleId });
                    table.ForeignKey(
                        name: "FK_Player_Roles_Players_Auth_UserId",
                        column: x => x.UserId,
                        principalTable: "Players_Auth",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Player_Roles_Roles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Role_Claims",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    RoleId = table.Column<int>(type: "integer", nullable: false),
                    ClaimType = table.Column<string>(type: "text", nullable: true),
                    ClaimValue = table.Column<string>(type: "text", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Role_Claims", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Role_Claims_Roles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AllianceInvitation",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    AllianceId = table.Column<int>(type: "integer", nullable: false),
                    PlayerId = table.Column<int>(type: "integer", nullable: false),
                    InvitedById = table.Column<int>(type: "integer", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    IsAccepted = table.Column<bool>(type: "boolean", nullable: false),
                    IsRejected = table.Column<bool>(type: "boolean", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AllianceInvitation", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AllianceRole",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    AllianceId = table.Column<int>(type: "integer", nullable: false),
                    PlayerId = table.Column<int>(type: "integer", nullable: false),
                    Rank = table.Column<int>(type: "integer", nullable: false),
                    AssignedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    AssignedById = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AllianceRole", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Alliances",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    Tag = table.Column<string>(type: "character varying(5)", maxLength: 5, nullable: false),
                    KingdomId = table.Column<int>(type: "integer", nullable: false),
                    LeaderId = table.Column<int>(type: "integer", nullable: false),
                    Level = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
                    Power = table.Column<long>(type: "bigint", nullable: false, defaultValue: 0L),
                    ExperiencePoints = table.Column<long>(type: "bigint", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
                    IsActive = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
                    MaxMembers = table.Column<int>(type: "integer", nullable: false, defaultValue: 50),
                    Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
                    WelcomeMessage = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
                    IsOpenToJoin = table.Column<bool>(type: "boolean", nullable: false),
                    RequireApproval = table.Column<bool>(type: "boolean", nullable: false),
                    MinCastleLevelToJoin = table.Column<int>(type: "integer", nullable: false),
                    MinPowerToJoin = table.Column<long>(type: "bigint", nullable: false),
                    FortressX = table.Column<int>(type: "integer", nullable: false),
                    FortressY = table.Column<int>(type: "integer", nullable: false),
                    FortressLevel = table.Column<int>(type: "integer", nullable: false),
                    TowerCount = table.Column<int>(type: "integer", nullable: false),
                    ResourceBuildingCount = table.Column<int>(type: "integer", nullable: false),
                    HasTerritory = table.Column<bool>(type: "boolean", nullable: false),
                    MilitaryAttackResearch = table.Column<int>(type: "integer", nullable: false),
                    MilitaryDefenseResearch = table.Column<int>(type: "integer", nullable: false),
                    MilitaryHealthResearch = table.Column<int>(type: "integer", nullable: false),
                    MilitarySpeedResearch = table.Column<int>(type: "integer", nullable: false),
                    MilitaryCapacityResearch = table.Column<int>(type: "integer", nullable: false),
                    EconomicGatheringResearch = table.Column<int>(type: "integer", nullable: false),
                    EconomicStorageResearch = table.Column<int>(type: "integer", nullable: false),
                    EconomicTradeResearch = table.Column<int>(type: "integer", nullable: false),
                    EconomicProductionResearch = table.Column<int>(type: "integer", nullable: false),
                    EconomicTaxationResearch = table.Column<int>(type: "integer", nullable: false),
                    TechnologyConstructionResearch = table.Column<int>(type: "integer", nullable: false),
                    TechnologyUpgradeResearch = table.Column<int>(type: "integer", nullable: false),
                    TechnologyTrainingResearch = table.Column<int>(type: "integer", nullable: false),
                    TechnologyResearchResearch = table.Column<int>(type: "integer", nullable: false),
                    TechnologyHealingResearch = table.Column<int>(type: "integer", nullable: false),
                    TotalKills = table.Column<long>(type: "bigint", nullable: false),
                    TotalDeaths = table.Column<long>(type: "bigint", nullable: false),
                    ResourcesGathered = table.Column<long>(type: "bigint", nullable: false),
                    ResourcesShared = table.Column<long>(type: "bigint", nullable: false),
                    KvKParticipations = table.Column<int>(type: "integer", nullable: false),
                    KvKWins = table.Column<int>(type: "integer", nullable: false),
                    LastKvKParticipation = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    CurrentCoalitionId = table.Column<int>(type: "integer", nullable: true),
                    IsEligibleForKvK = table.Column<bool>(type: "boolean", nullable: false),
                    AcceptsCoalitionInvites = table.Column<bool>(type: "boolean", nullable: false),
                    CoalitionReputationScore = table.Column<int>(type: "integer", nullable: false),
                    TreasuryFood = table.Column<long>(type: "bigint", nullable: false),
                    TreasuryWood = table.Column<long>(type: "bigint", nullable: false),
                    TreasuryIron = table.Column<long>(type: "bigint", nullable: false),
                    TreasurySilver = table.Column<long>(type: "bigint", nullable: false),
                    TreasuryMithril = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Alliances", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Alliances_Kingdoms_KingdomId",
                        column: x => x.KingdomId,
                        principalTable: "Kingdoms",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Players",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    KingdomId = table.Column<int>(type: "integer", nullable: false),
                    AllianceId = table.Column<int>(type: "integer", nullable: true),
                    CastleLevel = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
                    Power = table.Column<long>(type: "bigint", nullable: false, defaultValue: 0L),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
                    LastActiveAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
                    IsActive = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
                    CoordinateX = table.Column<int>(type: "integer", nullable: false),
                    CoordinateY = table.Column<int>(type: "integer", nullable: false),
                    Food = table.Column<long>(type: "bigint", nullable: false),
                    Wood = table.Column<long>(type: "bigint", nullable: false),
                    Iron = table.Column<long>(type: "bigint", nullable: false),
                    Silver = table.Column<long>(type: "bigint", nullable: false),
                    Mithril = table.Column<long>(type: "bigint", nullable: false),
                    FoodProtected = table.Column<long>(type: "bigint", nullable: false),
                    WoodProtected = table.Column<long>(type: "bigint", nullable: false),
                    IronProtected = table.Column<long>(type: "bigint", nullable: false),
                    SilverProtected = table.Column<long>(type: "bigint", nullable: false),
                    MithrilProtected = table.Column<long>(type: "bigint", nullable: false),
                    Gold = table.Column<int>(type: "integer", nullable: false),
                    InfantryT1 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT1 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT1 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT1 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT2 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT2 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT2 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT2 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT3 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT3 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT3 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT3 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT4 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT4 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT4 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT4 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT5 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT5 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT5 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT5 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT10 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT10 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT10 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT10 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT11 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT11 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT11 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT11 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT12 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT12 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT12 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT12 = table.Column<long>(type: "bigint", nullable: false),
                    InfantryT13 = table.Column<long>(type: "bigint", nullable: false),
                    CavalryT13 = table.Column<long>(type: "bigint", nullable: false),
                    BowmenT13 = table.Column<long>(type: "bigint", nullable: false),
                    SiegeT13 = table.Column<long>(type: "bigint", nullable: false),
                    AttacksWon = table.Column<long>(type: "bigint", nullable: false),
                    AttacksLost = table.Column<long>(type: "bigint", nullable: false),
                    DefensesWon = table.Column<long>(type: "bigint", nullable: false),
                    DefensesLost = table.Column<long>(type: "bigint", nullable: false),
                    TroopsKilled = table.Column<long>(type: "bigint", nullable: false),
                    TroopsLost = table.Column<long>(type: "bigint", nullable: false),
                    ResourcesGathered = table.Column<long>(type: "bigint", nullable: false),
                    ResourcesRaided = table.Column<long>(type: "bigint", nullable: false),
                    AcceptAllianceInvites = table.Column<bool>(type: "boolean", nullable: false),
                    ShowOnlineStatus = table.Column<bool>(type: "boolean", nullable: false),
                    EnablePushNotifications = table.Column<bool>(type: "boolean", nullable: false),
                    AutoUseSpeedBoosts = table.Column<bool>(type: "boolean", nullable: false),
                    Biography = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
                    VipLevel = table.Column<int>(type: "integer", nullable: false),
                    VipExpiryDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    HasActiveDragon = table.Column<bool>(type: "boolean", nullable: false),
                    DragonExpiryDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Players", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Players_Alliances_AllianceId",
                        column: x => x.AllianceId,
                        principalTable: "Alliances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.SetNull);
                    table.ForeignKey(
                        name: "FK_Players_Kingdoms_KingdomId",
                        column: x => x.KingdomId,
                        principalTable: "Kingdoms",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "CombatLogs",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    AttackerPlayerId = table.Column<int>(type: "integer", nullable: false),
                    DefenderPlayerId = table.Column<int>(type: "integer", nullable: false),
                    KingdomId = table.Column<int>(type: "integer", nullable: false),
                    AttackerAllianceId = table.Column<int>(type: "integer", nullable: true),
                    DefenderAllianceId = table.Column<int>(type: "integer", nullable: true),
                    CombatType = table.Column<int>(type: "integer", nullable: false),
                    Result = table.Column<int>(type: "integer", nullable: false),
                    Timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
                    BattleX = table.Column<int>(type: "integer", nullable: false),
                    BattleY = table.Column<int>(type: "integer", nullable: false),
                    WasFieldInterception = table.Column<bool>(type: "boolean", nullable: false),
                    InterceptorPlayerId = table.Column<int>(type: "integer", nullable: true),
                    InterceptionType = table.Column<int>(type: "integer", nullable: true),
                    MarchStartTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    MarchArrivalTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    MarchDurationSeconds = table.Column<int>(type: "integer", nullable: false),
                    UsedSpeedBoosts = table.Column<bool>(type: "boolean", nullable: false),
                    SpeedBoostLevel = table.Column<int>(type: "integer", nullable: false),
                    AttackerInfantryBefore = table.Column<long>(type: "bigint", nullable: false),
                    AttackerCavalryBefore = table.Column<long>(type: "bigint", nullable: false),
                    AttackerBowmenBefore = table.Column<long>(type: "bigint", nullable: false),
                    AttackerSiegeBefore = table.Column<long>(type: "bigint", nullable: false),
                    AttackerHighestTroopTier = table.Column<int>(type: "integer", nullable: false),
                    AttackerInfantryAfter = table.Column<long>(type: "bigint", nullable: false),
                    AttackerCavalryAfter = table.Column<long>(type: "bigint", nullable: false),
                    AttackerBowmenAfter = table.Column<long>(type: "bigint", nullable: false),
                    AttackerSiegeAfter = table.Column<long>(type: "bigint", nullable: false),
                    DefenderInfantryBefore = table.Column<long>(type: "bigint", nullable: false),
                    DefenderCavalryBefore = table.Column<long>(type: "bigint", nullable: false),
                    DefenderBowmenBefore = table.Column<long>(type: "bigint", nullable: false),
                    DefenderSiegeBefore = table.Column<long>(type: "bigint", nullable: false),
                    DefenderHighestTroopTier = table.Column<int>(type: "integer", nullable: false),
                    DefenderInfantryAfter = table.Column<long>(type: "bigint", nullable: false),
                    DefenderCavalryAfter = table.Column<long>(type: "bigint", nullable: false),
                    DefenderBowmenAfter = table.Column<long>(type: "bigint", nullable: false),
                    DefenderSiegeAfter = table.Column<long>(type: "bigint", nullable: false),
                    AttackerPowerBefore = table.Column<long>(type: "bigint", nullable: false),
                    DefenderPowerBefore = table.Column<long>(type: "bigint", nullable: false),
                    AttackerCasualties = table.Column<long>(type: "bigint", nullable: false),
                    DefenderCasualties = table.Column<long>(type: "bigint", nullable: false),
                    AttackerWoundedTroops = table.Column<long>(type: "bigint", nullable: false),
                    DefenderWoundedTroops = table.Column<long>(type: "bigint", nullable: false),
                    AttackerHadDragon = table.Column<bool>(type: "boolean", nullable: false),
                    DefenderHadDragon = table.Column<bool>(type: "boolean", nullable: false),
                    AttackerDragonSkillsUsed = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    DefenderDragonSkillsUsed = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    AttackerDragonBonus = table.Column<double>(type: "double precision", nullable: false),
                    DefenderDragonBonus = table.Column<double>(type: "double precision", nullable: false),
                    FoodTransferred = table.Column<long>(type: "bigint", nullable: false),
                    WoodTransferred = table.Column<long>(type: "bigint", nullable: false),
                    IronTransferred = table.Column<long>(type: "bigint", nullable: false),
                    SilverTransferred = table.Column<long>(type: "bigint", nullable: false),
                    MithrilTransferred = table.Column<long>(type: "bigint", nullable: false),
                    AttackerAllianceAttackBonus = table.Column<double>(type: "double precision", nullable: false),
                    AttackerAllianceDefenseBonus = table.Column<double>(type: "double precision", nullable: false),
                    AttackerAllianceHealthBonus = table.Column<double>(type: "double precision", nullable: false),
                    DefenderAllianceAttackBonus = table.Column<double>(type: "double precision", nullable: false),
                    DefenderAllianceDefenseBonus = table.Column<double>(type: "double precision", nullable: false),
                    DefenderAllianceHealthBonus = table.Column<double>(type: "double precision", nullable: false),
                    WasKvKBattle = table.Column<bool>(type: "boolean", nullable: false),
                    KvKEventId = table.Column<int>(type: "integer", nullable: true),
                    CoalitionId = table.Column<int>(type: "integer", nullable: true),
                    WasInForestZone = table.Column<bool>(type: "boolean", nullable: false),
                    ForestSpeedReduction = table.Column<double>(type: "double precision", nullable: false),
                    DetailedBattleReport = table.Column<string>(type: "character varying(4000)", maxLength: 4000, nullable: true),
                    BattleNotes = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
                    AttackerPlayerId1 = table.Column<int>(type: "integer", nullable: false),
                    DefenderPlayerId1 = table.Column<int>(type: "integer", nullable: false),
                    KingdomId1 = table.Column<int>(type: "integer", nullable: false),
                    AttackerAllianceId1 = table.Column<int>(type: "integer", nullable: true),
                    DefenderAllianceId1 = table.Column<int>(type: "integer", nullable: true),
                    InterceptorPlayerId1 = table.Column<int>(type: "integer", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CombatLogs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Alliances_AttackerAllianceId",
                        column: x => x.AttackerAllianceId,
                        principalTable: "Alliances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.SetNull);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Alliances_AttackerAllianceId1",
                        column: x => x.AttackerAllianceId1,
                        principalTable: "Alliances",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_CombatLogs_Alliances_DefenderAllianceId",
                        column: x => x.DefenderAllianceId,
                        principalTable: "Alliances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.SetNull);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Alliances_DefenderAllianceId1",
                        column: x => x.DefenderAllianceId1,
                        principalTable: "Alliances",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_CombatLogs_Kingdoms_KingdomId",
                        column: x => x.KingdomId,
                        principalTable: "Kingdoms",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Kingdoms_KingdomId1",
                        column: x => x.KingdomId1,
                        principalTable: "Kingdoms",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Players_AttackerPlayerId",
                        column: x => x.AttackerPlayerId,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Players_AttackerPlayerId1",
                        column: x => x.AttackerPlayerId1,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Players_DefenderPlayerId",
                        column: x => x.DefenderPlayerId,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Players_DefenderPlayerId1",
                        column: x => x.DefenderPlayerId1,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Players_InterceptorPlayerId",
                        column: x => x.InterceptorPlayerId,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_CombatLogs_Players_InterceptorPlayerId1",
                        column: x => x.InterceptorPlayerId1,
                        principalTable: "Players",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "PurchaseLogs",
                columns: table => new
                {
                    Id = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    PlayerId = table.Column<int>(type: "integer", nullable: false),
                    KingdomId = table.Column<int>(type: "integer", nullable: false),
                    AllianceId = table.Column<int>(type: "integer", nullable: true),
                    ProductId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
                    ProductName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
                    PurchaseType = table.Column<int>(type: "integer", nullable: false),
                    PaymentMethod = table.Column<int>(type: "integer", nullable: false),
                    Amount = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    Currency = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
                    PurchaseDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
                    ProcessedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    Status = table.Column<int>(type: "integer", nullable: false),
                    TransactionId = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
                    PlatformTransactionId = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
                    PlatformReceiptData = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
                    Platform = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
                    PlatformUserId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    DeviceInfo = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    IPAddress = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    UserAgent = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
                    GoldPurchased = table.Column<int>(type: "integer", nullable: false),
                    GoldSpent = table.Column<int>(type: "integer", nullable: false),
                    GoldBalanceBefore = table.Column<int>(type: "integer", nullable: false),
                    GoldBalanceAfter = table.Column<int>(type: "integer", nullable: false),
                    PlatformFee = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    NetRevenue = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    TaxAmount = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    RefundAmount = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    IsChargedBack = table.Column<bool>(type: "boolean", nullable: false),
                    ChargebackDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    ChargebackReason = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
                    ChargebackPenalty = table.Column<decimal>(type: "numeric(18,2)", nullable: true),
                    IsSuspicious = table.Column<bool>(type: "boolean", nullable: false),
                    FraudReason = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
                    IsRefunded = table.Column<bool>(type: "boolean", nullable: false),
                    RefundDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    RefundReason = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
                    IsConfirmed = table.Column<bool>(type: "boolean", nullable: false),
                    Notes = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
                    IsVipPurchase = table.Column<bool>(type: "boolean", nullable: false),
                    VipLevelBefore = table.Column<int>(type: "integer", nullable: false),
                    VipLevelAfter = table.Column<int>(type: "integer", nullable: false),
                    VipDaysAdded = table.Column<int>(type: "integer", nullable: false),
                    VipPointsEarned = table.Column<int>(type: "integer", nullable: false),
                    VipPointsBefore = table.Column<int>(type: "integer", nullable: false),
                    VipPointsAfter = table.Column<int>(type: "integer", nullable: false),
                    TriggeredVipMilestone = table.Column<bool>(type: "boolean", nullable: false),
                    VipMilestoneReached = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    IsEligibleForMonthlyReward = table.Column<bool>(type: "boolean", nullable: false),
                    IsEligibleForYearlyReward = table.Column<bool>(type: "boolean", nullable: false),
                    SecretSpendingTierBefore = table.Column<int>(type: "integer", nullable: false),
                    SecretSpendingTierAfter = table.Column<int>(type: "integer", nullable: false),
                    UnlockedNewSecretTier = table.Column<bool>(type: "boolean", nullable: false),
                    IsDragonPurchase = table.Column<bool>(type: "boolean", nullable: false),
                    DragonType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    DragonDaysAdded = table.Column<int>(type: "integer", nullable: false),
                    DragonSkillsUnlocked = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
                    IsSpeedBoostPurchase = table.Column<bool>(type: "boolean", nullable: false),
                    SpeedBoostQuantity = table.Column<int>(type: "integer", nullable: false),
                    SpeedBoostLevel = table.Column<int>(type: "integer", nullable: false),
                    SpeedBoostHours = table.Column<int>(type: "integer", nullable: false),
                    IsStealthPurchase = table.Column<bool>(type: "boolean", nullable: false),
                    StealthUsesAdded = table.Column<int>(type: "integer", nullable: false),
                    StealthType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    IsResourcePackage = table.Column<bool>(type: "boolean", nullable: false),
                    FoodReceived = table.Column<long>(type: "bigint", nullable: false),
                    WoodReceived = table.Column<long>(type: "bigint", nullable: false),
                    IronReceived = table.Column<long>(type: "bigint", nullable: false),
                    SilverReceived = table.Column<long>(type: "bigint", nullable: false),
                    MithrilReceived = table.Column<long>(type: "bigint", nullable: false),
                    IsConstructionBoost = table.Column<bool>(type: "boolean", nullable: false),
                    IsTrainingBoost = table.Column<bool>(type: "boolean", nullable: false),
                    IsResearchBoost = table.Column<bool>(type: "boolean", nullable: false),
                    BoostHours = table.Column<int>(type: "integer", nullable: false),
                    BoostPercentage = table.Column<int>(type: "integer", nullable: false),
                    SkillAlternativeUsed = table.Column<double>(type: "double precision", nullable: false),
                    HasSkillBasedAlternative = table.Column<bool>(type: "boolean", nullable: false),
                    SkillAlternativeDescription = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
                    TimeInvestmentHours = table.Column<decimal>(type: "numeric(8,2)", nullable: false),
                    IsBundle = table.Column<bool>(type: "boolean", nullable: false),
                    BundleContents = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
                    BundleDiscountPercentage = table.Column<double>(type: "double precision", nullable: false),
                    WasRefunded = table.Column<bool>(type: "boolean", nullable: false),
                    RefundedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    WasChargeback = table.Column<bool>(type: "boolean", nullable: false),
                    ChargebackAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    ChargebackDisputeDeadline = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    ChargebackDisputed = table.Column<bool>(type: "boolean", nullable: false),
                    DisputeStatus = table.Column<int>(type: "integer", nullable: true),
                    ChargebackFee = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    FraudScore = table.Column<int>(type: "integer", nullable: false),
                    IsFraudSuspected = table.Column<bool>(type: "boolean", nullable: false),
                    FraudNotes = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
                    RequiresManualReview = table.Column<bool>(type: "boolean", nullable: false),
                    IsHighRiskTransaction = table.Column<bool>(type: "boolean", nullable: false),
                    MinutesFromRegistration = table.Column<int>(type: "integer", nullable: false),
                    PurchasesInLast24Hours = table.Column<int>(type: "integer", nullable: false),
                    SpendingInLast24Hours = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    IsVelocityFlagged = table.Column<bool>(type: "boolean", nullable: false),
                    IsNewDevicePurchase = table.Column<bool>(type: "boolean", nullable: false),
                    MonthlySpendingBefore = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    MonthlySpendingAfter = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    LifetimeSpendingBefore = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    LifetimeSpendingAfter = table.Column<decimal>(type: "numeric(18,2)", nullable: false),
                    MonthlyPurchaseCount = table.Column<int>(type: "integer", nullable: false),
                    LifetimePurchaseCount = table.Column<int>(type: "integer", nullable: false),
                    DetailedPurchaseData = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
                    PurchaseNotes = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
                    CampaignId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    PromotionCode = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    IsFirstPurchase = table.Column<bool>(type: "boolean", nullable: false),
                    IsFirstMonthlyPurchase = table.Column<bool>(type: "boolean", nullable: false),
                    DaysSinceLastPurchase = table.Column<int>(type: "integer", nullable: false),
                    PlayerId1 = table.Column<int>(type: "integer", nullable: false),
                    KingdomId1 = table.Column<int>(type: "integer", nullable: false),
                    AllianceId1 = table.Column<int>(type: "integer", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PurchaseLogs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PurchaseLogs_Alliances_AllianceId",
                        column: x => x.AllianceId,
                        principalTable: "Alliances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.SetNull);
                    table.ForeignKey(
                        name: "FK_PurchaseLogs_Alliances_AllianceId1",
                        column: x => x.AllianceId1,
                        principalTable: "Alliances",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_PurchaseLogs_Kingdoms_KingdomId",
                        column: x => x.KingdomId,
                        principalTable: "Kingdoms",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_PurchaseLogs_Kingdoms_KingdomId1",
                        column: x => x.KingdomId1,
                        principalTable: "Kingdoms",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PurchaseLogs_Players_PlayerId",
                        column: x => x.PlayerId,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_PurchaseLogs_Players_PlayerId1",
                        column: x => x.PlayerId1,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AllianceInvitation_AllianceId",
                table: "AllianceInvitation",
                column: "AllianceId");

            migrationBuilder.CreateIndex(
                name: "IX_AllianceInvitation_InvitedById",
                table: "AllianceInvitation",
                column: "InvitedById");

            migrationBuilder.CreateIndex(
                name: "IX_AllianceInvitation_PlayerId",
                table: "AllianceInvitation",
                column: "PlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_AllianceRole_AllianceId",
                table: "AllianceRole",
                column: "AllianceId");

            migrationBuilder.CreateIndex(
                name: "IX_AllianceRole_AssignedById",
                table: "AllianceRole",
                column: "AssignedById");

            migrationBuilder.CreateIndex(
                name: "IX_AllianceRole_PlayerId",
                table: "AllianceRole",
                column: "PlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_Alliances_Kingdom_Power",
                table: "Alliances",
                columns: new[] { "KingdomId", "Power" });

            migrationBuilder.CreateIndex(
                name: "IX_Alliances_KingdomId",
                table: "Alliances",
                column: "KingdomId");

            migrationBuilder.CreateIndex(
                name: "IX_Alliances_LeaderId",
                table: "Alliances",
                column: "LeaderId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Alliances_Name",
                table: "Alliances",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Alliances_Power",
                table: "Alliances",
                column: "Power");

            migrationBuilder.CreateIndex(
                name: "IX_Alliances_Tag",
                table: "Alliances",
                column: "Tag");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_AttackerAllianceId",
                table: "CombatLogs",
                column: "AttackerAllianceId");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_AttackerAllianceId1",
                table: "CombatLogs",
                column: "AttackerAllianceId1");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_AttackerPlayerId",
                table: "CombatLogs",
                column: "AttackerPlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_AttackerPlayerId1",
                table: "CombatLogs",
                column: "AttackerPlayerId1");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_DefenderAllianceId",
                table: "CombatLogs",
                column: "DefenderAllianceId");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_DefenderAllianceId1",
                table: "CombatLogs",
                column: "DefenderAllianceId1");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_DefenderPlayerId",
                table: "CombatLogs",
                column: "DefenderPlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_DefenderPlayerId1",
                table: "CombatLogs",
                column: "DefenderPlayerId1");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_InterceptorPlayerId",
                table: "CombatLogs",
                column: "InterceptorPlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_InterceptorPlayerId1",
                table: "CombatLogs",
                column: "InterceptorPlayerId1");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_Kingdom_Time",
                table: "CombatLogs",
                columns: new[] { "KingdomId", "Timestamp" });

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_KingdomId",
                table: "CombatLogs",
                column: "KingdomId");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_KingdomId1",
                table: "CombatLogs",
                column: "KingdomId1");

            migrationBuilder.CreateIndex(
                name: "IX_CombatLogs_Timestamp",
                table: "CombatLogs",
                column: "Timestamp");

            migrationBuilder.CreateIndex(
                name: "IX_Kingdoms_Name",
                table: "Kingdoms",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Kingdoms_Number",
                table: "Kingdoms",
                column: "Number",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Player_Claims_UserId",
                table: "Player_Claims",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_Player_Logins_UserId",
                table: "Player_Logins",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_Player_Roles_RoleId",
                table: "Player_Roles",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_Players_AllianceId",
                table: "Players",
                column: "AllianceId");

            migrationBuilder.CreateIndex(
                name: "IX_Players_Kingdom_Alliance",
                table: "Players",
                columns: new[] { "KingdomId", "AllianceId" });

            migrationBuilder.CreateIndex(
                name: "IX_Players_Kingdom_Power",
                table: "Players",
                columns: new[] { "KingdomId", "Power" });

            migrationBuilder.CreateIndex(
                name: "IX_Players_KingdomId",
                table: "Players",
                column: "KingdomId");

            migrationBuilder.CreateIndex(
                name: "IX_Players_Name",
                table: "Players",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Players_Power",
                table: "Players",
                column: "Power");

            migrationBuilder.CreateIndex(
                name: "EmailIndex",
                table: "Players_Auth",
                column: "NormalizedEmail");

            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "Players_Auth",
                column: "NormalizedUserName",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_AllianceId",
                table: "PurchaseLogs",
                column: "AllianceId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_AllianceId1",
                table: "PurchaseLogs",
                column: "AllianceId1");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_Kingdom_Time",
                table: "PurchaseLogs",
                columns: new[] { "KingdomId", "PurchaseDate" });

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_KingdomId",
                table: "PurchaseLogs",
                column: "KingdomId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_KingdomId1",
                table: "PurchaseLogs",
                column: "KingdomId1");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_PlayerId",
                table: "PurchaseLogs",
                column: "PlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_PlayerId1",
                table: "PurchaseLogs",
                column: "PlayerId1");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_PurchaseDate",
                table: "PurchaseLogs",
                column: "PurchaseDate");

            migrationBuilder.CreateIndex(
                name: "IX_PurchaseLogs_TransactionId",
                table: "PurchaseLogs",
                column: "TransactionId");

            migrationBuilder.CreateIndex(
                name: "IX_Role_Claims_RoleId",
                table: "Role_Claims",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "Roles",
                column: "NormalizedName",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_AllianceInvitation_Alliances_AllianceId",
                table: "AllianceInvitation",
                column: "AllianceId",
                principalTable: "Alliances",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AllianceInvitation_Players_InvitedById",
                table: "AllianceInvitation",
                column: "InvitedById",
                principalTable: "Players",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AllianceInvitation_Players_PlayerId",
                table: "AllianceInvitation",
                column: "PlayerId",
                principalTable: "Players",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AllianceRole_Alliances_AllianceId",
                table: "AllianceRole",
                column: "AllianceId",
                principalTable: "Alliances",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AllianceRole_Players_AssignedById",
                table: "AllianceRole",
                column: "AssignedById",
                principalTable: "Players",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AllianceRole_Players_PlayerId",
                table: "AllianceRole",
                column: "PlayerId",
                principalTable: "Players",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Alliances_Players_LeaderId",
                table: "Alliances",
                column: "LeaderId",
                principalTable: "Players",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Players_Alliances_AllianceId",
                table: "Players");

            migrationBuilder.DropTable(
                name: "AllianceInvitation");

            migrationBuilder.DropTable(
                name: "AllianceRole");

            migrationBuilder.DropTable(
                name: "CombatLogs");

            migrationBuilder.DropTable(
                name: "Player_Claims");

            migrationBuilder.DropTable(
                name: "Player_Logins");

            migrationBuilder.DropTable(
                name: "Player_Roles");

            migrationBuilder.DropTable(
                name: "Player_Tokens");

            migrationBuilder.DropTable(
                name: "PurchaseLogs");

            migrationBuilder.DropTable(
                name: "Role_Claims");

            migrationBuilder.DropTable(
                name: "Players_Auth");

            migrationBuilder.DropTable(
                name: "Roles");

            migrationBuilder.DropTable(
                name: "Alliances");

            migrationBuilder.DropTable(
                name: "Players");

            migrationBuilder.DropTable(
                name: "Kingdoms");
        }
    }
}
