From 3f3bb3cefc4c886b42a178e38512ae8949b4926e Mon Sep 17 00:00:00 2001 From: Paweł Bernaciak Date: Sun, 22 Oct 2023 15:54:54 +0200 Subject: Fix icon storage in suggestion --- .../Migrations/20231022092319_Initial.Designer.cs | 249 --------------------- .../Migrations/20231022092319_Initial.cs | 190 ---------------- .../Migrations/20231022135245_Initial.Designer.cs | 249 +++++++++++++++++++++ .../Migrations/20231022135245_Initial.cs | 190 ++++++++++++++++ .../ApplicationDbContextModelSnapshot.cs | 4 +- backend/Elements.Data/Models/Suggestion.cs | 2 +- 6 files changed, 442 insertions(+), 442 deletions(-) delete mode 100644 backend/Elements.Data/Migrations/20231022092319_Initial.Designer.cs delete mode 100644 backend/Elements.Data/Migrations/20231022092319_Initial.cs create mode 100644 backend/Elements.Data/Migrations/20231022135245_Initial.Designer.cs create mode 100644 backend/Elements.Data/Migrations/20231022135245_Initial.cs (limited to 'backend') diff --git a/backend/Elements.Data/Migrations/20231022092319_Initial.Designer.cs b/backend/Elements.Data/Migrations/20231022092319_Initial.Designer.cs deleted file mode 100644 index 41c4295..0000000 --- a/backend/Elements.Data/Migrations/20231022092319_Initial.Designer.cs +++ /dev/null @@ -1,249 +0,0 @@ -// -using System; -using Elements.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Elements.Data.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20231022092319_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.12"); - - modelBuilder.Entity("Elements.Data.Models.Element", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("IconPng") - .IsRequired() - .HasColumnType("BLOB"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("State") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Elements"); - - b.HasData( - new - { - Id = 1, - IconPng = 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 }, - Name = "Fire", - State = 1, - UserId = 1 - }, - new - { - Id = 2, - IconPng = 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 }, - Name = "Water", - State = 1, - UserId = 1 - }, - new - { - Id = 3, - IconPng = 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 }, - Name = "Air", - State = 1, - UserId = 1 - }, - new - { - Id = 4, - IconPng = 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 }, - Name = "Ground", - State = 1, - UserId = 1 - }); - }); - - modelBuilder.Entity("Elements.Data.Models.Recipe", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FirstIngredientId") - .HasColumnType("INTEGER"); - - b.Property("ResultId") - .HasColumnType("INTEGER"); - - b.Property("SecondIngredientId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("FirstIngredientId"); - - b.HasIndex("ResultId"); - - b.HasIndex("SecondIngredientId"); - - b.ToTable("Recipes"); - }); - - modelBuilder.Entity("Elements.Data.Models.Suggestion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FirstIngredientId") - .HasColumnType("INTEGER"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("SecondIngredientId") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.Property("Votes") - .HasColumnType("INTEGER"); - - b.Property("VotingEnd") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("FirstIngredientId"); - - b.HasIndex("SecondIngredientId"); - - b.HasIndex("UserId"); - - b.ToTable("Suggestions"); - }); - - modelBuilder.Entity("Elements.Data.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("GoogleId") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - - b.HasData( - new - { - Id = 1, - GoogleId = "", - Name = "Elements" - }); - }); - - modelBuilder.Entity("Elements.Data.Models.Element", b => - { - b.HasOne("Elements.Data.Models.User", "User") - .WithMany("Elements") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Elements.Data.Models.Recipe", b => - { - b.HasOne("Elements.Data.Models.Element", "FirstIngredient") - .WithMany() - .HasForeignKey("FirstIngredientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Elements.Data.Models.Element", "Result") - .WithMany() - .HasForeignKey("ResultId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Elements.Data.Models.Element", "SecondIngredient") - .WithMany() - .HasForeignKey("SecondIngredientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FirstIngredient"); - - b.Navigation("Result"); - - b.Navigation("SecondIngredient"); - }); - - modelBuilder.Entity("Elements.Data.Models.Suggestion", b => - { - b.HasOne("Elements.Data.Models.Element", "FirstIngredient") - .WithMany() - .HasForeignKey("FirstIngredientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Elements.Data.Models.Element", "SecondIngredient") - .WithMany() - .HasForeignKey("SecondIngredientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Elements.Data.Models.User", null) - .WithMany("Suggestions") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FirstIngredient"); - - b.Navigation("SecondIngredient"); - }); - - modelBuilder.Entity("Elements.Data.Models.User", b => - { - b.Navigation("Elements"); - - b.Navigation("Suggestions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/backend/Elements.Data/Migrations/20231022092319_Initial.cs b/backend/Elements.Data/Migrations/20231022092319_Initial.cs deleted file mode 100644 index 313f86f..0000000 --- a/backend/Elements.Data/Migrations/20231022092319_Initial.cs +++ /dev/null @@ -1,190 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace Elements.Data.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GoogleId = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Elements", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column(type: "INTEGER", nullable: false), - Name = table.Column(type: "TEXT", nullable: false), - State = table.Column(type: "INTEGER", nullable: false), - IconPng = table.Column(type: "BLOB", 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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - FirstIngredientId = table.Column(type: "INTEGER", nullable: false), - SecondIngredientId = table.Column(type: "INTEGER", nullable: false), - ResultId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Recipes", x => x.Id); - table.ForeignKey( - name: "FK_Recipes_Elements_FirstIngredientId", - column: x => x.FirstIngredientId, - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Recipes_Elements_ResultId", - column: x => x.ResultId, - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Recipes_Elements_SecondIngredientId", - column: x => x.SecondIngredientId, - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Suggestions", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", nullable: false), - Icon = table.Column(type: "TEXT", nullable: false), - FirstIngredientId = table.Column(type: "INTEGER", nullable: false), - SecondIngredientId = table.Column(type: "INTEGER", nullable: false), - VotingEnd = table.Column(type: "TEXT", nullable: false), - Votes = table.Column(type: "INTEGER", nullable: false), - UserId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Suggestions", x => x.Id); - table.ForeignKey( - name: "FK_Suggestions_Elements_FirstIngredientId", - column: x => x.FirstIngredientId, - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Suggestions_Elements_SecondIngredientId", - column: x => x.SecondIngredientId, - 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.InsertData( - table: "Users", - columns: new[] { "Id", "GoogleId", "Name" }, - values: new object[] { 1, "", "Elements" }); - - migrationBuilder.InsertData( - table: "Elements", - columns: new[] { "Id", "IconPng", "Name", "State", "UserId" }, - values: new object[,] - { - { 1, 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 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 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 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_FirstIngredientId", - table: "Recipes", - column: "FirstIngredientId"); - - migrationBuilder.CreateIndex( - name: "IX_Recipes_ResultId", - table: "Recipes", - column: "ResultId"); - - migrationBuilder.CreateIndex( - name: "IX_Recipes_SecondIngredientId", - table: "Recipes", - column: "SecondIngredientId"); - - migrationBuilder.CreateIndex( - name: "IX_Suggestions_FirstIngredientId", - table: "Suggestions", - column: "FirstIngredientId"); - - migrationBuilder.CreateIndex( - name: "IX_Suggestions_SecondIngredientId", - table: "Suggestions", - column: "SecondIngredientId"); - - migrationBuilder.CreateIndex( - name: "IX_Suggestions_UserId", - table: "Suggestions", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Recipes"); - - migrationBuilder.DropTable( - name: "Suggestions"); - - migrationBuilder.DropTable( - name: "Elements"); - - migrationBuilder.DropTable( - name: "Users"); - } - } -} diff --git a/backend/Elements.Data/Migrations/20231022135245_Initial.Designer.cs b/backend/Elements.Data/Migrations/20231022135245_Initial.Designer.cs new file mode 100644 index 0000000..cb525bd --- /dev/null +++ b/backend/Elements.Data/Migrations/20231022135245_Initial.Designer.cs @@ -0,0 +1,249 @@ +// +using System; +using Elements.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Elements.Data.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20231022135245_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.12"); + + modelBuilder.Entity("Elements.Data.Models.Element", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("IconPng") + .IsRequired() + .HasColumnType("BLOB"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("State") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Elements"); + + b.HasData( + new + { + Id = 1, + IconPng = 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 }, + Name = "Fire", + State = 1, + UserId = 1 + }, + new + { + Id = 2, + IconPng = 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 }, + Name = "Water", + State = 1, + UserId = 1 + }, + new + { + Id = 3, + IconPng = 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 }, + Name = "Air", + State = 1, + UserId = 1 + }, + new + { + Id = 4, + IconPng = 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 }, + Name = "Ground", + State = 1, + UserId = 1 + }); + }); + + modelBuilder.Entity("Elements.Data.Models.Recipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FirstIngredientId") + .HasColumnType("INTEGER"); + + b.Property("ResultId") + .HasColumnType("INTEGER"); + + b.Property("SecondIngredientId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("FirstIngredientId"); + + b.HasIndex("ResultId"); + + b.HasIndex("SecondIngredientId"); + + b.ToTable("Recipes"); + }); + + modelBuilder.Entity("Elements.Data.Models.Suggestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FirstIngredientId") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("BLOB"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SecondIngredientId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.Property("Votes") + .HasColumnType("INTEGER"); + + b.Property("VotingEnd") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FirstIngredientId"); + + b.HasIndex("SecondIngredientId"); + + b.HasIndex("UserId"); + + b.ToTable("Suggestions"); + }); + + modelBuilder.Entity("Elements.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GoogleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Users"); + + b.HasData( + new + { + Id = 1, + GoogleId = "", + Name = "Elements" + }); + }); + + modelBuilder.Entity("Elements.Data.Models.Element", b => + { + b.HasOne("Elements.Data.Models.User", "User") + .WithMany("Elements") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Elements.Data.Models.Recipe", b => + { + b.HasOne("Elements.Data.Models.Element", "FirstIngredient") + .WithMany() + .HasForeignKey("FirstIngredientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elements.Data.Models.Element", "Result") + .WithMany() + .HasForeignKey("ResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elements.Data.Models.Element", "SecondIngredient") + .WithMany() + .HasForeignKey("SecondIngredientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstIngredient"); + + b.Navigation("Result"); + + b.Navigation("SecondIngredient"); + }); + + modelBuilder.Entity("Elements.Data.Models.Suggestion", b => + { + b.HasOne("Elements.Data.Models.Element", "FirstIngredient") + .WithMany() + .HasForeignKey("FirstIngredientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elements.Data.Models.Element", "SecondIngredient") + .WithMany() + .HasForeignKey("SecondIngredientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elements.Data.Models.User", null) + .WithMany("Suggestions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FirstIngredient"); + + b.Navigation("SecondIngredient"); + }); + + modelBuilder.Entity("Elements.Data.Models.User", b => + { + b.Navigation("Elements"); + + b.Navigation("Suggestions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/Elements.Data/Migrations/20231022135245_Initial.cs b/backend/Elements.Data/Migrations/20231022135245_Initial.cs new file mode 100644 index 0000000..1b203db --- /dev/null +++ b/backend/Elements.Data/Migrations/20231022135245_Initial.cs @@ -0,0 +1,190 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Elements.Data.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GoogleId = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Elements", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + UserId = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", nullable: false), + State = table.Column(type: "INTEGER", nullable: false), + IconPng = table.Column(type: "BLOB", 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(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FirstIngredientId = table.Column(type: "INTEGER", nullable: false), + SecondIngredientId = table.Column(type: "INTEGER", nullable: false), + ResultId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Recipes", x => x.Id); + table.ForeignKey( + name: "FK_Recipes_Elements_FirstIngredientId", + column: x => x.FirstIngredientId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Recipes_Elements_ResultId", + column: x => x.ResultId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Recipes_Elements_SecondIngredientId", + column: x => x.SecondIngredientId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Suggestions", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "BLOB", nullable: false), + FirstIngredientId = table.Column(type: "INTEGER", nullable: false), + SecondIngredientId = table.Column(type: "INTEGER", nullable: false), + VotingEnd = table.Column(type: "TEXT", nullable: false), + Votes = table.Column(type: "INTEGER", nullable: false), + UserId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Suggestions", x => x.Id); + table.ForeignKey( + name: "FK_Suggestions_Elements_FirstIngredientId", + column: x => x.FirstIngredientId, + principalTable: "Elements", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Suggestions_Elements_SecondIngredientId", + column: x => x.SecondIngredientId, + 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.InsertData( + table: "Users", + columns: new[] { "Id", "GoogleId", "Name" }, + values: new object[] { 1, "", "Elements" }); + + migrationBuilder.InsertData( + table: "Elements", + columns: new[] { "Id", "IconPng", "Name", "State", "UserId" }, + values: new object[,] + { + { 1, 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 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 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 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_FirstIngredientId", + table: "Recipes", + column: "FirstIngredientId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_ResultId", + table: "Recipes", + column: "ResultId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_SecondIngredientId", + table: "Recipes", + column: "SecondIngredientId"); + + migrationBuilder.CreateIndex( + name: "IX_Suggestions_FirstIngredientId", + table: "Suggestions", + column: "FirstIngredientId"); + + migrationBuilder.CreateIndex( + name: "IX_Suggestions_SecondIngredientId", + table: "Suggestions", + column: "SecondIngredientId"); + + migrationBuilder.CreateIndex( + name: "IX_Suggestions_UserId", + table: "Suggestions", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Recipes"); + + migrationBuilder.DropTable( + name: "Suggestions"); + + migrationBuilder.DropTable( + name: "Elements"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs b/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs index 32bb909..095839f 100644 --- a/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -113,9 +113,9 @@ namespace Elements.Data.Migrations b.Property("FirstIngredientId") .HasColumnType("INTEGER"); - b.Property("Icon") + b.Property("Icon") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("BLOB"); b.Property("Name") .IsRequired() diff --git a/backend/Elements.Data/Models/Suggestion.cs b/backend/Elements.Data/Models/Suggestion.cs index ac442ec..3d626fc 100644 --- a/backend/Elements.Data/Models/Suggestion.cs +++ b/backend/Elements.Data/Models/Suggestion.cs @@ -4,7 +4,7 @@ public class Suggestion { public int Id { get; set; } public required string Name { get; init; } - public required string Icon { get; init; } + public required byte[] Icon { get; init; } public required Element FirstIngredient { get; init; } public required Element SecondIngredient { get; init; } public required DateTime VotingEnd { get; init; } -- cgit v1.2.3