using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using System; using System.Collections.Generic; namespace SharedLibraryCore.Migrations.Postgresql { public partial class InitialCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "EFAliasLinks", columns: table => new { AliasLinkId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFAliasLinks", x => x.AliasLinkId); }); migrationBuilder.CreateTable( name: "EFServers", columns: table => new { ServerId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), Port = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFServers", x => x.ServerId); }); migrationBuilder.CreateTable( name: "Vector3", columns: table => new { Vector3Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), X = table.Column(nullable: false), Y = table.Column(nullable: false), Z = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Vector3", x => x.Vector3Id); }); migrationBuilder.CreateTable( name: "EFAlias", columns: table => new { AliasId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), DateAdded = table.Column(nullable: false), IPAddress = table.Column(nullable: false), LinkId = table.Column(nullable: false), Name = table.Column(maxLength: 128, nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFAlias", x => x.AliasId); table.ForeignKey( name: "FK_EFAlias_EFAliasLinks_LinkId", column: x => x.LinkId, principalTable: "EFAliasLinks", principalColumn: "AliasLinkId", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "EFServerStatistics", columns: table => new { StatisticId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), ServerId = table.Column(nullable: false), TotalKills = table.Column(nullable: false), TotalPlayTime = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFServerStatistics", x => x.StatisticId); table.ForeignKey( name: "FK_EFServerStatistics_EFServers_ServerId", column: x => x.ServerId, principalTable: "EFServers", principalColumn: "ServerId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EFClients", columns: table => new { ClientId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), AliasLinkId = table.Column(nullable: false), Connections = table.Column(nullable: false), CurrentAliasId = table.Column(nullable: false), FirstConnection = table.Column(nullable: false), LastConnection = table.Column(nullable: false), Level = table.Column(nullable: false), Masked = table.Column(nullable: false), NetworkId = table.Column(nullable: false), Password = table.Column(nullable: true), PasswordSalt = table.Column(nullable: true), TotalConnectionTime = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFClients", x => x.ClientId); table.ForeignKey( name: "FK_EFClients_EFAliasLinks_AliasLinkId", column: x => x.AliasLinkId, principalTable: "EFAliasLinks", principalColumn: "AliasLinkId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFClients_EFAlias_CurrentAliasId", column: x => x.CurrentAliasId, principalTable: "EFAlias", principalColumn: "AliasId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EFClientKills", columns: table => new { KillId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true). Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), AttackerId = table.Column(nullable: false), Damage = table.Column(nullable: false), DeathOriginVector3Id = table.Column(nullable: true), DeathType = table.Column(nullable: false), HitLoc = table.Column(nullable: false), KillOriginVector3Id = table.Column(nullable: true), Map = table.Column(nullable: false), ServerId = table.Column(nullable: false), VictimId = table.Column(nullable: false), ViewAnglesVector3Id = table.Column(nullable: true), Weapon = table.Column(nullable: false), When = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFClientKills", x => x.KillId); table.ForeignKey( name: "FK_EFClientKills_EFClients_AttackerId", column: x => x.AttackerId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFClientKills_Vector3_DeathOriginVector3Id", column: x => x.DeathOriginVector3Id, principalTable: "Vector3", principalColumn: "Vector3Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_EFClientKills_Vector3_KillOriginVector3Id", column: x => x.KillOriginVector3Id, principalTable: "Vector3", principalColumn: "Vector3Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_EFClientKills_EFServers_ServerId", column: x => x.ServerId, principalTable: "EFServers", principalColumn: "ServerId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFClientKills_EFClients_VictimId", column: x => x.VictimId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFClientKills_Vector3_ViewAnglesVector3Id", column: x => x.ViewAnglesVector3Id, principalTable: "Vector3", principalColumn: "Vector3Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "EFClientMessages", columns: table => new { MessageId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), ClientId = table.Column(nullable: false), Message = table.Column(nullable: true), ServerId = table.Column(nullable: false), TimeSent = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFClientMessages", x => x.MessageId); table.ForeignKey( name: "FK_EFClientMessages_EFClients_ClientId", column: x => x.ClientId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFClientMessages_EFServers_ServerId", column: x => x.ServerId, principalTable: "EFServers", principalColumn: "ServerId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EFClientStatistics", columns: table => new { ClientId = table.Column(nullable: false), ServerId = table.Column(nullable: false), Active = table.Column(nullable: false), Deaths = table.Column(nullable: false), Kills = table.Column(nullable: false), SPM = table.Column(nullable: false), Skill = table.Column(nullable: false), TimePlayed = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFClientStatistics", x => new { x.ClientId, x.ServerId }); table.ForeignKey( name: "FK_EFClientStatistics_EFClients_ClientId", column: x => x.ClientId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFClientStatistics_EFServers_ServerId", column: x => x.ServerId, principalTable: "EFServers", principalColumn: "ServerId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EFPenalties", columns: table => new { PenaltyId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), Expires = table.Column(nullable: false), LinkId = table.Column(nullable: false), OffenderId = table.Column(nullable: false), Offense = table.Column(nullable: false), PunisherId = table.Column(nullable: false), Type = table.Column(nullable: false), When = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFPenalties", x => x.PenaltyId); table.ForeignKey( name: "FK_EFPenalties_EFAliasLinks_LinkId", column: x => x.LinkId, principalTable: "EFAliasLinks", principalColumn: "AliasLinkId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFPenalties_EFClients_OffenderId", column: x => x.OffenderId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_EFPenalties_EFClients_PunisherId", column: x => x.PunisherId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "EFHitLocationCounts", columns: table => new { HitLocationCountId = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true). Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), EFClientStatistics_ClientId = table.Column(nullable: false), HitCount = table.Column(nullable: false), HitOffsetAverage = table.Column(nullable: false), Location = table.Column(nullable: false), EFClientStatistics_ServerId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFHitLocationCounts", x => x.HitLocationCountId); table.ForeignKey( name: "FK_EFHitLocationCounts_EFClients_EFClientStatistics_ClientId", column: x => x.EFClientStatistics_ClientId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFHitLocationCounts_EFServers_EFClientStatistics_ServerId", column: x => x.EFClientStatistics_ServerId, principalTable: "EFServers", principalColumn: "ServerId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFHitLocationCounts_EFClientStatistics_EFClientStatistics_ClientId_EFClientStatistics_ServerId", columns: x => new { x.EFClientStatistics_ClientId, x.EFClientStatistics_ServerId }, principalTable: "EFClientStatistics", principalColumns: new[] { "ClientId", "ServerId" }, onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_EFAlias_LinkId", table: "EFAlias", column: "LinkId"); migrationBuilder.CreateIndex( name: "IX_EFClientKills_AttackerId", table: "EFClientKills", column: "AttackerId"); migrationBuilder.CreateIndex( name: "IX_EFClientKills_DeathOriginVector3Id", table: "EFClientKills", column: "DeathOriginVector3Id"); migrationBuilder.CreateIndex( name: "IX_EFClientKills_KillOriginVector3Id", table: "EFClientKills", column: "KillOriginVector3Id"); migrationBuilder.CreateIndex( name: "IX_EFClientKills_ServerId", table: "EFClientKills", column: "ServerId"); migrationBuilder.CreateIndex( name: "IX_EFClientKills_VictimId", table: "EFClientKills", column: "VictimId"); migrationBuilder.CreateIndex( name: "IX_EFClientKills_ViewAnglesVector3Id", table: "EFClientKills", column: "ViewAnglesVector3Id"); migrationBuilder.CreateIndex( name: "IX_EFClientMessages_ClientId", table: "EFClientMessages", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_EFClientMessages_ServerId", table: "EFClientMessages", column: "ServerId"); migrationBuilder.CreateIndex( name: "IX_EFClients_AliasLinkId", table: "EFClients", column: "AliasLinkId"); migrationBuilder.CreateIndex( name: "IX_EFClients_CurrentAliasId", table: "EFClients", column: "CurrentAliasId"); migrationBuilder.CreateIndex( name: "IX_EFClients_NetworkId", table: "EFClients", column: "NetworkId", unique: true); migrationBuilder.CreateIndex( name: "IX_EFClientStatistics_ServerId", table: "EFClientStatistics", column: "ServerId"); migrationBuilder.CreateIndex( name: "IX_EFHitLocationCounts_EFClientStatistics_ServerId", table: "EFHitLocationCounts", column: "EFClientStatistics_ServerId"); migrationBuilder.CreateIndex( name: "IX_EFHitLocationCounts_EFClientStatistics_ClientId_EFClientStatistics_ServerId", table: "EFHitLocationCounts", columns: new[] { "EFClientStatistics_ClientId", "EFClientStatistics_ServerId" }); migrationBuilder.CreateIndex( name: "IX_EFPenalties_LinkId", table: "EFPenalties", column: "LinkId"); migrationBuilder.CreateIndex( name: "IX_EFPenalties_OffenderId", table: "EFPenalties", column: "OffenderId"); migrationBuilder.CreateIndex( name: "IX_EFPenalties_PunisherId", table: "EFPenalties", column: "PunisherId"); migrationBuilder.CreateIndex( name: "IX_EFServerStatistics_ServerId", table: "EFServerStatistics", column: "ServerId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "EFClientKills"); migrationBuilder.DropTable( name: "EFClientMessages"); migrationBuilder.DropTable( name: "EFHitLocationCounts"); migrationBuilder.DropTable( name: "EFPenalties"); migrationBuilder.DropTable( name: "EFServerStatistics"); migrationBuilder.DropTable( name: "Vector3"); migrationBuilder.DropTable( name: "EFClientStatistics"); migrationBuilder.DropTable( name: "EFClients"); migrationBuilder.DropTable( name: "EFServers"); migrationBuilder.DropTable( name: "EFAlias"); migrationBuilder.DropTable( name: "EFAliasLinks"); } } }