|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using Microsoft.EntityFrameworkCore.Migrations; |
| 4 | +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
| 5 | + |
| 6 | +#nullable disable |
| 7 | + |
| 8 | +namespace Server.Migrations |
| 9 | +{ |
| 10 | + /// <inheritdoc /> |
| 11 | + public partial class DbLeaderboards : Migration |
| 12 | + { |
| 13 | + /// <inheritdoc /> |
| 14 | + protected override void Up(MigrationBuilder migrationBuilder) |
| 15 | + { |
| 16 | + migrationBuilder.CreateTable( |
| 17 | + name: "LeaderboardDefinitions", |
| 18 | + columns: table => new |
| 19 | + { |
| 20 | + Name = table.Column<string>(type: "text", nullable: false), |
| 21 | + TrackedData = table.Column<string>(type: "text", nullable: false), |
| 22 | + ExtraInfo = table.Column<string>(type: "text", nullable: true), |
| 23 | + NameColumn = table.Column<string>(type: "text", nullable: false) |
| 24 | + }, |
| 25 | + constraints: table => |
| 26 | + { |
| 27 | + table.PrimaryKey("PK_LeaderboardDefinitions", x => x.Name); |
| 28 | + }); |
| 29 | + |
| 30 | + migrationBuilder.CreateTable( |
| 31 | + name: "Leaderboards", |
| 32 | + columns: table => new |
| 33 | + { |
| 34 | + Id = table.Column<int>(type: "integer", nullable: false) |
| 35 | + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
| 36 | + Servers = table.Column<List<string>>(type: "text[]", nullable: false), |
| 37 | + Count = table.Column<int>(type: "integer", nullable: false), |
| 38 | + Position = table.Column<int>(type: "integer", nullable: false), |
| 39 | + PlayerGuid = table.Column<Guid>(type: "uuid", nullable: true), |
| 40 | + Username = table.Column<string>(type: "text", nullable: false), |
| 41 | + LeaderboardDefinitionName = table.Column<string>(type: "text", nullable: false) |
| 42 | + }, |
| 43 | + constraints: table => |
| 44 | + { |
| 45 | + table.PrimaryKey("PK_Leaderboards", x => x.Id); |
| 46 | + table.ForeignKey( |
| 47 | + name: "FK_Leaderboards_LeaderboardDefinitions_LeaderboardDefinitionNa~", |
| 48 | + column: x => x.LeaderboardDefinitionName, |
| 49 | + principalTable: "LeaderboardDefinitions", |
| 50 | + principalColumn: "Name", |
| 51 | + onDelete: ReferentialAction.Cascade); |
| 52 | + }); |
| 53 | + |
| 54 | + migrationBuilder.CreateIndex( |
| 55 | + name: "IX_Leaderboards_LeaderboardDefinitionName", |
| 56 | + table: "Leaderboards", |
| 57 | + column: "LeaderboardDefinitionName"); |
| 58 | + } |
| 59 | + |
| 60 | + /// <inheritdoc /> |
| 61 | + protected override void Down(MigrationBuilder migrationBuilder) |
| 62 | + { |
| 63 | + migrationBuilder.DropTable( |
| 64 | + name: "Leaderboards"); |
| 65 | + |
| 66 | + migrationBuilder.DropTable( |
| 67 | + name: "LeaderboardDefinitions"); |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments