diff options
Diffstat (limited to 'backend/Elements.Data/Migrations/20231028175352_Initial.cs')
| -rw-r--r-- | backend/Elements.Data/Migrations/20231028175352_Initial.cs | 231 |
1 files changed, 231 insertions, 0 deletions
diff --git a/backend/Elements.Data/Migrations/20231028175352_Initial.cs b/backend/Elements.Data/Migrations/20231028175352_Initial.cs new file mode 100644 index 0000000..1169982 --- /dev/null +++ b/backend/Elements.Data/Migrations/20231028175352_Initial.cs @@ -0,0 +1,231 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Elements.Data.Migrations +{ + /// <inheritdoc /> + public partial class Initial : Migration + { + /// <inheritdoc /> + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + GoogleId = table.Column<string>(type: "text", nullable: false), + Name = table.Column<string>(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Elements", + columns: table => new + { + Id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + UserId = table.Column<int>(type: "integer", nullable: false), + Name = table.Column<string>(type: "text", nullable: false), + State = table.Column<int>(type: "integer", nullable: false), + IconPng = table.Column<byte[]>(type: "bytea", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Elements", x => x.Id); + table.ForeignKey( + name: "FK_Elements_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Recipes", + columns: table => new + { + Id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + FirstElementId = table.Column<int>(type: "integer", nullable: false), + SecondElementId = table.Column<int>(type: "integer", nullable: false), + ResultElementId = table.Column<int>(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Recipes", x => x.Id); + table.ForeignKey( + name: "FK_Recipes_Elements_FirstElementId", + column: x => x.FirstElementId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Recipes_Elements_ResultElementId", + column: x => x.ResultElementId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Recipes_Elements_SecondElementId", + column: x => x.SecondElementId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Suggestions", + columns: table => new + { + Id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + Name = table.Column<string>(type: "text", nullable: false), + Icon = table.Column<byte[]>(type: "bytea", nullable: false), + FirstElementId = table.Column<int>(type: "integer", nullable: false), + SecondElementId = table.Column<int>(type: "integer", nullable: false), + VotingEnd = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + UserId = table.Column<int>(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Suggestions", x => x.Id); + table.ForeignKey( + name: "FK_Suggestions_Elements_FirstElementId", + column: x => x.FirstElementId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Suggestions_Elements_SecondElementId", + column: x => x.SecondElementId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Suggestions_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Votes", + columns: table => new + { + Id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column<int>(type: "integer", nullable: false), + SuggestionId = table.Column<int>(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Votes", x => x.Id); + table.ForeignKey( + name: "FK_Votes_Suggestions_SuggestionId", + column: x => x.SuggestionId, + principalTable: "Suggestions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Votes_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "Users", + columns: new[] { "Id", "GoogleId", "Name" }, + values: new object[] { 1, "", "Elements" }); + + migrationBuilder.InsertData( + table: "Elements", + columns: new[] { "Id", "CreationDate", "IconPng", "Name", "State", "UserId" }, + values: new object[,] + { + { 1, new DateTime(2023, 10, 28, 17, 53, 52, 688, DateTimeKind.Utc).AddTicks(9070), new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 249, 95, 224, 252, 159, 129, 2, 192, 194, 64, 33, 24, 53, 96, 212, 128, 81, 3, 6, 139, 1, 0, 119, 65, 2, 242, 233, 108, 215, 141, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 }, "Fire", 1, 1 }, + { 2, new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(230), new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 81, 156, 246, 249, 63, 3, 5, 128, 133, 129, 66, 48, 106, 192, 168, 1, 163, 6, 12, 22, 3, 0, 85, 67, 2, 234, 36, 203, 134, 16, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 }, "Water", 1, 1 }, + { 3, new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(720), new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 30, 73, 68, 65, 84, 120, 156, 99, 217, 125, 239, 247, 127, 6, 10, 0, 11, 3, 133, 96, 212, 128, 81, 3, 70, 13, 24, 44, 6, 0, 0, 10, 221, 3, 212, 197, 89, 182, 174, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 }, "Air", 1, 1 }, + { 4, new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(1160), new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 137, 117, 48, 255, 207, 64, 1, 96, 97, 160, 16, 140, 26, 48, 106, 192, 168, 1, 131, 197, 0, 0, 242, 75, 2, 20, 1, 55, 196, 168, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 }, "Ground", 1, 1 } + }); + + migrationBuilder.CreateIndex( + name: "IX_Elements_UserId", + table: "Elements", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_FirstElementId", + table: "Recipes", + column: "FirstElementId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_ResultElementId", + table: "Recipes", + column: "ResultElementId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_SecondElementId", + table: "Recipes", + column: "SecondElementId"); + + migrationBuilder.CreateIndex( + name: "IX_Suggestions_FirstElementId", + table: "Suggestions", + column: "FirstElementId"); + + migrationBuilder.CreateIndex( + name: "IX_Suggestions_SecondElementId", + table: "Suggestions", + column: "SecondElementId"); + + migrationBuilder.CreateIndex( + name: "IX_Suggestions_UserId", + table: "Suggestions", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Votes_SuggestionId", + table: "Votes", + column: "SuggestionId"); + + migrationBuilder.CreateIndex( + name: "IX_Votes_UserId", + table: "Votes", + column: "UserId"); + } + + /// <inheritdoc /> + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Recipes"); + + migrationBuilder.DropTable( + name: "Votes"); + + migrationBuilder.DropTable( + name: "Suggestions"); + + migrationBuilder.DropTable( + name: "Elements"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} |
