|
| 1 | +using System; |
| 2 | +using Microsoft.EntityFrameworkCore.Metadata; |
| 3 | +using Microsoft.EntityFrameworkCore.Migrations; |
| 4 | + |
| 5 | +#nullable disable |
| 6 | + |
| 7 | +namespace MysqlMigrations.Migrations |
| 8 | +{ |
| 9 | + /// <inheritdoc /> |
| 10 | + public partial class Challenge : Migration |
| 11 | + { |
| 12 | + /// <inheritdoc /> |
| 13 | + protected override void Up(MigrationBuilder migrationBuilder) |
| 14 | + { |
| 15 | + migrationBuilder.CreateTable( |
| 16 | + name: "SpChallenges", |
| 17 | + columns: table => new |
| 18 | + { |
| 19 | + SpChallengeId = table.Column<int>(type: "int", nullable: false) |
| 20 | + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
| 21 | + GameMode = table.Column<int>(type: "int", nullable: false), |
| 22 | + Commander = table.Column<int>(type: "int", nullable: false), |
| 23 | + Fen = table.Column<string>(type: "varchar(1000)", maxLength: 1000, nullable: false) |
| 24 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 25 | + Base64Image = table.Column<string>(type: "longtext", nullable: false) |
| 26 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 27 | + Time = table.Column<int>(type: "int", nullable: false), |
| 28 | + WinnerPlayerId = table.Column<int>(type: "int", nullable: true), |
| 29 | + Active = table.Column<bool>(type: "tinyint(1)", nullable: false), |
| 30 | + CreatedAt = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: false) |
| 31 | + }, |
| 32 | + constraints: table => |
| 33 | + { |
| 34 | + table.PrimaryKey("PK_SpChallenges", x => x.SpChallengeId); |
| 35 | + table.ForeignKey( |
| 36 | + name: "FK_SpChallenges_Players_WinnerPlayerId", |
| 37 | + column: x => x.WinnerPlayerId, |
| 38 | + principalTable: "Players", |
| 39 | + principalColumn: "PlayerId"); |
| 40 | + }) |
| 41 | + .Annotation("MySql:CharSet", "utf8mb4"); |
| 42 | + |
| 43 | + migrationBuilder.CreateTable( |
| 44 | + name: "SpChallengeSubmissions", |
| 45 | + columns: table => new |
| 46 | + { |
| 47 | + SpChallengeSubmissionId = table.Column<int>(type: "int", nullable: false) |
| 48 | + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
| 49 | + Submitted = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: false), |
| 50 | + GameTime = table.Column<DateTime>(type: "datetime(0)", precision: 0, nullable: false), |
| 51 | + Commander = table.Column<int>(type: "int", nullable: false), |
| 52 | + Fen = table.Column<string>(type: "varchar(1000)", maxLength: 1000, nullable: false) |
| 53 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 54 | + Time = table.Column<int>(type: "int", nullable: false), |
| 55 | + SpChallengeId = table.Column<int>(type: "int", nullable: false), |
| 56 | + PlayerId = table.Column<int>(type: "int", nullable: false) |
| 57 | + }, |
| 58 | + constraints: table => |
| 59 | + { |
| 60 | + table.PrimaryKey("PK_SpChallengeSubmissions", x => x.SpChallengeSubmissionId); |
| 61 | + table.ForeignKey( |
| 62 | + name: "FK_SpChallengeSubmissions_Players_PlayerId", |
| 63 | + column: x => x.PlayerId, |
| 64 | + principalTable: "Players", |
| 65 | + principalColumn: "PlayerId", |
| 66 | + onDelete: ReferentialAction.Cascade); |
| 67 | + table.ForeignKey( |
| 68 | + name: "FK_SpChallengeSubmissions_SpChallenges_SpChallengeId", |
| 69 | + column: x => x.SpChallengeId, |
| 70 | + principalTable: "SpChallenges", |
| 71 | + principalColumn: "SpChallengeId", |
| 72 | + onDelete: ReferentialAction.Cascade); |
| 73 | + }) |
| 74 | + .Annotation("MySql:CharSet", "utf8mb4"); |
| 75 | + |
| 76 | + migrationBuilder.CreateIndex( |
| 77 | + name: "IX_SpChallengeSubmissions_PlayerId", |
| 78 | + table: "SpChallengeSubmissions", |
| 79 | + column: "PlayerId"); |
| 80 | + |
| 81 | + migrationBuilder.CreateIndex( |
| 82 | + name: "IX_SpChallengeSubmissions_SpChallengeId", |
| 83 | + table: "SpChallengeSubmissions", |
| 84 | + column: "SpChallengeId"); |
| 85 | + |
| 86 | + migrationBuilder.CreateIndex( |
| 87 | + name: "IX_SpChallenges_WinnerPlayerId", |
| 88 | + table: "SpChallenges", |
| 89 | + column: "WinnerPlayerId"); |
| 90 | + } |
| 91 | + |
| 92 | + /// <inheritdoc /> |
| 93 | + protected override void Down(MigrationBuilder migrationBuilder) |
| 94 | + { |
| 95 | + migrationBuilder.DropTable( |
| 96 | + name: "SpChallengeSubmissions"); |
| 97 | + |
| 98 | + migrationBuilder.DropTable( |
| 99 | + name: "SpChallenges"); |
| 100 | + } |
| 101 | + } |
| 102 | +} |
0 commit comments