diff options
20 files changed, 339 insertions, 615 deletions
@@ -472,6 +472,5 @@ elements.db-wal .http -.vscode .env diff --git a/backend/.vscode/launch.json b/backend/.vscode/launch.json new file mode 100644 index 0000000..474e526 --- /dev/null +++ b/backend/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug .NET Core in Docker", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickRemoteProcess}", + "sourceFileMap": { + "/app/Elements.Backend": "${workspaceRoot}/Elements.Backend" + }, + "pipeTransport": { + "pipeCwd": "${workspaceRoot}", + "pipeProgram": "docker", + "pipeArgs": ["exec", "-i", "elements-backend-dev"], + "quoteArgs": false, + "debuggerPath": "/vsdbg/vsdbg" + } + } + ] +} diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..658ff67 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder +WORKDIR /app + +COPY . ./ + +WORKDIR /app/Elements.Backend + +RUN dotnet restore +RUN dotnet publish -c Release -o out + +FROM mcr.microsoft.com/dotnet/aspnet:7.0 +WORKDIR /app +COPY --from=builder /app/Elements.Backend/out . +ENTRYPOINT ["dotnet", "Elements.Backend.dll"] diff --git a/backend/Elements.Backend/Elements.Backend.csproj b/backend/Elements.Backend/Elements.Backend.csproj index 787d048..426b45a 100644 --- a/backend/Elements.Backend/Elements.Backend.csproj +++ b/backend/Elements.Backend/Elements.Backend.csproj @@ -4,7 +4,7 @@ <TargetFramework>net7.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> - <UserSecretsId>dae266ca-b349-4b87-a992-5470f9dd635d</UserSecretsId> + <DebugType>portable</DebugType> </PropertyGroup> <ItemGroup> @@ -17,6 +17,7 @@ </PackageReference> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.12" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.10" /> + <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> </ItemGroup> diff --git a/backend/Elements.Backend/Program.cs b/backend/Elements.Backend/Program.cs index f7b9b4b..6804d1a 100644 --- a/backend/Elements.Backend/Program.cs +++ b/backend/Elements.Backend/Program.cs @@ -14,13 +14,11 @@ builder.Services.AddControllers().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});
-if (builder.Environment.IsDevelopment())
+builder.Services.AddDbContext<ApplicationDbContext>(options =>
{
- builder.Services.AddDbContext<ApplicationDbContext>(options =>
- {
- options.UseSqlite("Data Source=elements.db");
- });
-}
+ options.UseNpgsql(Environment.GetEnvironmentVariable("ELEM_DB_CONN_STR") ??
+ "Server=database;Port=5432;Database=elements;User Id=elements;Password=elementspass");
+});
builder.Services
.AddAuthentication(options =>
@@ -52,6 +50,12 @@ builder.Services.AddHostedService( var app = builder.Build();
+using (var scope = app.Services.CreateScope())
+{
+ ApplicationDbContext context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
+ context.Database.Migrate();
+}
+
app.UseHttpsRedirection();
app.UseAuthentication();
diff --git a/backend/Elements.Backend/Properties/launchSettings.json b/backend/Elements.Backend/Properties/launchSettings.json index 0a48056..1114d6c 100644 --- a/backend/Elements.Backend/Properties/launchSettings.json +++ b/backend/Elements.Backend/Properties/launchSettings.json @@ -12,9 +12,7 @@ "http": {
"commandName": "Project",
"dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "http://localhost:5102",
+ "applicationUrl": "http://0.0.0.0:5102",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
diff --git a/backend/Elements.Data/ApplicationContextFactory.cs b/backend/Elements.Data/ApplicationContextFactory.cs index b8e4ebd..76f11e1 100644 --- a/backend/Elements.Data/ApplicationContextFactory.cs +++ b/backend/Elements.Data/ApplicationContextFactory.cs @@ -8,7 +8,7 @@ public class ApplicationContextFactory : IDesignTimeDbContextFactory<Application public ApplicationDbContext CreateDbContext(string[] args) { DbContextOptionsBuilder<ApplicationDbContext> optionsBuilder = new(); - optionsBuilder.UseSqlite("Data Source=elements.db"); + optionsBuilder.UseNpgsql("Server=database;Port=5432;Database=elements;User Id=elements;Password=elementspass"); return new ApplicationDbContext(optionsBuilder.Options); } diff --git a/backend/Elements.Data/Elements.Data.csproj b/backend/Elements.Data/Elements.Data.csproj index a6d9fa3..30c7fc9 100644 --- a/backend/Elements.Data/Elements.Data.csproj +++ b/backend/Elements.Data/Elements.Data.csproj @@ -4,16 +4,18 @@ <TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+ <DebugType>portable</DebugType>
</PropertyGroup>
- <ItemGroup> - <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.12"> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - <PrivateAssets>all</PrivateAssets> - </PackageReference> - <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.12" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" /> - <PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" /> + <ItemGroup>
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.12">
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+ <PrivateAssets>all</PrivateAssets>
+ </PackageReference>
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.12" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" />
+ <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
+ <PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
</ItemGroup>
</Project>
diff --git a/backend/Elements.Data/Migrations/20231022191811_Initial.Designer.cs b/backend/Elements.Data/Migrations/20231022191811_Initial.Designer.cs deleted file mode 100644 index 72f90f1..0000000 --- a/backend/Elements.Data/Migrations/20231022191811_Initial.Designer.cs +++ /dev/null @@ -1,289 +0,0 @@ -// <auto-generated /> -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("20231022191811_Initial")] - partial class Initial - { - /// <inheritdoc /> - 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<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property<byte[]>("IconPng") - .IsRequired() - .HasColumnType("BLOB"); - - b.Property<string>("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property<int>("State") - .HasColumnType("INTEGER"); - - b.Property<int>("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<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property<int>("FirstIngredientId") - .HasColumnType("INTEGER"); - - b.Property<int>("ResultId") - .HasColumnType("INTEGER"); - - b.Property<int>("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<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property<int>("FirstElementId") - .HasColumnType("INTEGER"); - - b.Property<byte[]>("Icon") - .IsRequired() - .HasColumnType("BLOB"); - - b.Property<string>("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property<int>("SecondElementId") - .HasColumnType("INTEGER"); - - b.Property<int>("UserId") - .HasColumnType("INTEGER"); - - b.Property<DateTime>("VotingEnd") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("FirstElementId"); - - b.HasIndex("SecondElementId"); - - b.HasIndex("UserId"); - - b.ToTable("Suggestions"); - }); - - modelBuilder.Entity("Elements.Data.Models.User", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property<string>("GoogleId") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property<string>("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Users"); - - b.HasData( - new - { - Id = 1, - GoogleId = "", - Name = "Elements" - }); - }); - - modelBuilder.Entity("Elements.Data.Models.Vote", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property<int>("SuggestionId") - .HasColumnType("INTEGER"); - - b.Property<int>("UserId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("SuggestionId"); - - b.HasIndex("UserId"); - - b.ToTable("Votes"); - }); - - 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", "FirstElement") - .WithMany() - .HasForeignKey("FirstElementId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Elements.Data.Models.Element", "SecondElement") - .WithMany() - .HasForeignKey("SecondElementId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Elements.Data.Models.User", null) - .WithMany("Suggestions") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FirstElement"); - - b.Navigation("SecondElement"); - }); - - modelBuilder.Entity("Elements.Data.Models.Vote", b => - { - b.HasOne("Elements.Data.Models.Suggestion", null) - .WithMany("Votes") - .HasForeignKey("SuggestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Elements.Data.Models.User", null) - .WithMany("Votes") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Elements.Data.Models.Suggestion", b => - { - b.Navigation("Votes"); - }); - - modelBuilder.Entity("Elements.Data.Models.User", b => - { - b.Navigation("Elements"); - - b.Navigation("Suggestions"); - - b.Navigation("Votes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs b/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs deleted file mode 100644 index 3612108..0000000 --- a/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Elements.Data.Migrations -{ - /// <inheritdoc /> - public partial class Addcreationdates : Migration - { - /// <inheritdoc /> - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Recipes_Elements_FirstIngredientId", - table: "Recipes"); - - migrationBuilder.DropForeignKey( - name: "FK_Recipes_Elements_ResultId", - table: "Recipes"); - - migrationBuilder.DropForeignKey( - name: "FK_Recipes_Elements_SecondIngredientId", - table: "Recipes"); - - migrationBuilder.RenameColumn( - name: "SecondIngredientId", - table: "Recipes", - newName: "SecondElementId"); - - migrationBuilder.RenameColumn( - name: "ResultId", - table: "Recipes", - newName: "ResultElementId"); - - migrationBuilder.RenameColumn( - name: "FirstIngredientId", - table: "Recipes", - newName: "FirstElementId"); - - migrationBuilder.RenameIndex( - name: "IX_Recipes_SecondIngredientId", - table: "Recipes", - newName: "IX_Recipes_SecondElementId"); - - migrationBuilder.RenameIndex( - name: "IX_Recipes_ResultId", - table: "Recipes", - newName: "IX_Recipes_ResultElementId"); - - migrationBuilder.RenameIndex( - name: "IX_Recipes_FirstIngredientId", - table: "Recipes", - newName: "IX_Recipes_FirstElementId"); - - migrationBuilder.AddColumn<DateTime>( - name: "CreationDate", - table: "Suggestions", - type: "TEXT", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn<DateTime>( - name: "CreationDate", - table: "Elements", - type: "TEXT", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.UpdateData( - table: "Elements", - keyColumn: "Id", - keyValue: 1, - column: "CreationDate", - value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(1750)); - - migrationBuilder.UpdateData( - table: "Elements", - keyColumn: "Id", - keyValue: 2, - column: "CreationDate", - value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(2880)); - - migrationBuilder.UpdateData( - table: "Elements", - keyColumn: "Id", - keyValue: 3, - column: "CreationDate", - value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3350)); - - migrationBuilder.UpdateData( - table: "Elements", - keyColumn: "Id", - keyValue: 4, - column: "CreationDate", - value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3790)); - - migrationBuilder.AddForeignKey( - name: "FK_Recipes_Elements_FirstElementId", - table: "Recipes", - column: "FirstElementId", - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Recipes_Elements_ResultElementId", - table: "Recipes", - column: "ResultElementId", - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Recipes_Elements_SecondElementId", - table: "Recipes", - column: "SecondElementId", - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// <inheritdoc /> - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Recipes_Elements_FirstElementId", - table: "Recipes"); - - migrationBuilder.DropForeignKey( - name: "FK_Recipes_Elements_ResultElementId", - table: "Recipes"); - - migrationBuilder.DropForeignKey( - name: "FK_Recipes_Elements_SecondElementId", - table: "Recipes"); - - migrationBuilder.DropColumn( - name: "CreationDate", - table: "Suggestions"); - - migrationBuilder.DropColumn( - name: "CreationDate", - table: "Elements"); - - migrationBuilder.RenameColumn( - name: "SecondElementId", - table: "Recipes", - newName: "SecondIngredientId"); - - migrationBuilder.RenameColumn( - name: "ResultElementId", - table: "Recipes", - newName: "ResultId"); - - migrationBuilder.RenameColumn( - name: "FirstElementId", - table: "Recipes", - newName: "FirstIngredientId"); - - migrationBuilder.RenameIndex( - name: "IX_Recipes_SecondElementId", - table: "Recipes", - newName: "IX_Recipes_SecondIngredientId"); - - migrationBuilder.RenameIndex( - name: "IX_Recipes_ResultElementId", - table: "Recipes", - newName: "IX_Recipes_ResultId"); - - migrationBuilder.RenameIndex( - name: "IX_Recipes_FirstElementId", - table: "Recipes", - newName: "IX_Recipes_FirstIngredientId"); - - migrationBuilder.AddForeignKey( - name: "FK_Recipes_Elements_FirstIngredientId", - table: "Recipes", - column: "FirstIngredientId", - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Recipes_Elements_ResultId", - table: "Recipes", - column: "ResultId", - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Recipes_Elements_SecondIngredientId", - table: "Recipes", - column: "SecondIngredientId", - principalTable: "Elements", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/backend/Elements.Data/Migrations/20231024192803_Add creation dates.Designer.cs b/backend/Elements.Data/Migrations/20231028175352_Initial.Designer.cs index ae7fa06..fbd1dbd 100644 --- a/backend/Elements.Data/Migrations/20231024192803_Add creation dates.Designer.cs +++ b/backend/Elements.Data/Migrations/20231028175352_Initial.Designer.cs @@ -5,43 +5,50 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Elements.Data.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20231024192803_Add creation dates")] - partial class Addcreationdates + [Migration("20231028175352_Initial")] + partial class Initial { /// <inheritdoc /> protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.12"); + modelBuilder + .HasAnnotation("ProductVersion", "7.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("Elements.Data.Models.Element", b => { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<DateTime>("CreationDate") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property<byte[]>("IconPng") .IsRequired() - .HasColumnType("BLOB"); + .HasColumnType("bytea"); b.Property<string>("Name") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property<int>("State") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("UserId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -53,7 +60,7 @@ namespace Elements.Data.Migrations new { Id = 1, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(1750), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 688, DateTimeKind.Utc).AddTicks(9070), 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, @@ -62,7 +69,7 @@ namespace Elements.Data.Migrations new { Id = 2, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(2880), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(230), 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, @@ -71,7 +78,7 @@ namespace Elements.Data.Migrations new { Id = 3, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3350), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(720), 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, @@ -80,7 +87,7 @@ namespace Elements.Data.Migrations new { Id = 4, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3790), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(1160), 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, @@ -92,16 +99,18 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<int>("FirstElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("ResultElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("SecondElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -118,30 +127,32 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<DateTime>("CreationDate") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property<int>("FirstElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<byte[]>("Icon") .IsRequired() - .HasColumnType("BLOB"); + .HasColumnType("bytea"); b.Property<string>("Name") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property<int>("SecondElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("UserId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<DateTime>("VotingEnd") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); @@ -158,15 +169,17 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<string>("GoogleId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property<string>("Name") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("Id"); @@ -185,13 +198,15 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<int>("SuggestionId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("UserId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("Id"); diff --git a/backend/Elements.Data/Migrations/20231022191811_Initial.cs b/backend/Elements.Data/Migrations/20231028175352_Initial.cs index 5885c27..1169982 100644 --- a/backend/Elements.Data/Migrations/20231022191811_Initial.cs +++ b/backend/Elements.Data/Migrations/20231028175352_Initial.cs @@ -1,5 +1,6 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -17,10 +18,10 @@ namespace Elements.Data.Migrations name: "Users", columns: table => new { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GoogleId = table.Column<string>(type: "TEXT", nullable: false), - Name = table.Column<string>(type: "TEXT", nullable: false) + 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 => { @@ -31,12 +32,13 @@ namespace Elements.Data.Migrations name: "Elements", columns: table => new { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - 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: "BLOB", nullable: false) + 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 => { @@ -53,30 +55,30 @@ namespace Elements.Data.Migrations name: "Recipes", columns: table => new { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - FirstIngredientId = table.Column<int>(type: "INTEGER", nullable: false), - SecondIngredientId = table.Column<int>(type: "INTEGER", nullable: false), - ResultId = table.Column<int>(type: "INTEGER", nullable: false) + 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_FirstIngredientId", - column: x => x.FirstIngredientId, + name: "FK_Recipes_Elements_FirstElementId", + column: x => x.FirstElementId, principalTable: "Elements", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_Recipes_Elements_ResultId", - column: x => x.ResultId, + name: "FK_Recipes_Elements_ResultElementId", + column: x => x.ResultElementId, principalTable: "Elements", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_Recipes_Elements_SecondIngredientId", - column: x => x.SecondIngredientId, + name: "FK_Recipes_Elements_SecondElementId", + column: x => x.SecondElementId, principalTable: "Elements", principalColumn: "Id", onDelete: ReferentialAction.Cascade); @@ -86,14 +88,15 @@ namespace Elements.Data.Migrations name: "Suggestions", columns: table => new { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column<string>(type: "TEXT", nullable: false), - Icon = table.Column<byte[]>(type: "BLOB", nullable: false), - FirstElementId = table.Column<int>(type: "INTEGER", nullable: false), - SecondElementId = table.Column<int>(type: "INTEGER", nullable: false), - VotingEnd = table.Column<DateTime>(type: "TEXT", nullable: false), - UserId = table.Column<int>(type: "INTEGER", nullable: false) + 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 => { @@ -122,10 +125,10 @@ namespace Elements.Data.Migrations name: "Votes", columns: table => new { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column<int>(type: "INTEGER", nullable: false), - SuggestionId = table.Column<int>(type: "INTEGER", nullable: false) + 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 => { @@ -151,13 +154,13 @@ namespace Elements.Data.Migrations migrationBuilder.InsertData( table: "Elements", - columns: new[] { "Id", "IconPng", "Name", "State", "UserId" }, + columns: new[] { "Id", "CreationDate", "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 } + { 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( @@ -166,19 +169,19 @@ namespace Elements.Data.Migrations column: "UserId"); migrationBuilder.CreateIndex( - name: "IX_Recipes_FirstIngredientId", + name: "IX_Recipes_FirstElementId", table: "Recipes", - column: "FirstIngredientId"); + column: "FirstElementId"); migrationBuilder.CreateIndex( - name: "IX_Recipes_ResultId", + name: "IX_Recipes_ResultElementId", table: "Recipes", - column: "ResultId"); + column: "ResultElementId"); migrationBuilder.CreateIndex( - name: "IX_Recipes_SecondIngredientId", + name: "IX_Recipes_SecondElementId", table: "Recipes", - column: "SecondIngredientId"); + column: "SecondElementId"); migrationBuilder.CreateIndex( name: "IX_Suggestions_FirstElementId", diff --git a/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs b/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs index 7b88425..779ed10 100644 --- a/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -4,6 +4,7 @@ using Elements.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -15,30 +16,36 @@ namespace Elements.Data.Migrations protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.12"); + modelBuilder + .HasAnnotation("ProductVersion", "7.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("Elements.Data.Models.Element", b => { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<DateTime>("CreationDate") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property<byte[]>("IconPng") .IsRequired() - .HasColumnType("BLOB"); + .HasColumnType("bytea"); b.Property<string>("Name") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property<int>("State") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("UserId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -50,7 +57,7 @@ namespace Elements.Data.Migrations new { Id = 1, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(1750), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 688, DateTimeKind.Utc).AddTicks(9070), 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, @@ -59,7 +66,7 @@ namespace Elements.Data.Migrations new { Id = 2, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(2880), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(230), 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, @@ -68,7 +75,7 @@ namespace Elements.Data.Migrations new { Id = 3, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3350), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(720), 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, @@ -77,7 +84,7 @@ namespace Elements.Data.Migrations new { Id = 4, - CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3790), + CreationDate = new DateTime(2023, 10, 28, 17, 53, 52, 689, DateTimeKind.Utc).AddTicks(1160), 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, @@ -89,16 +96,18 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<int>("FirstElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("ResultElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("SecondElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -115,30 +124,32 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<DateTime>("CreationDate") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property<int>("FirstElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<byte[]>("Icon") .IsRequired() - .HasColumnType("BLOB"); + .HasColumnType("bytea"); b.Property<string>("Name") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property<int>("SecondElementId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("UserId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<DateTime>("VotingEnd") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); @@ -155,15 +166,17 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<string>("GoogleId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property<string>("Name") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("Id"); @@ -182,13 +195,15 @@ namespace Elements.Data.Migrations { b.Property<int>("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); b.Property<int>("SuggestionId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property<int>("UserId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("Id"); diff --git a/backend/dev.Dockerfile b/backend/dev.Dockerfile new file mode 100644 index 0000000..578c65a --- /dev/null +++ b/backend/dev.Dockerfile @@ -0,0 +1,8 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 +WORKDIR /app + +RUN apt-get update \ + && apt-get install unzip \ + && curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /vsdbg + +CMD ["dotnet", "watch", "--non-interactive", "--no-hot-reload", "--project", "./Elements.Backend"]
\ No newline at end of file diff --git a/dev.docker-compose.yml b/dev.docker-compose.yml new file mode 100644 index 0000000..eb8791f --- /dev/null +++ b/dev.docker-compose.yml @@ -0,0 +1,51 @@ +version: '3.8' +services: + frontend: + build: + context: ./frontend + dockerfile: dev.Dockerfile + container_name: elements-frontend-dev + ports: + - 3000:80 + volumes: + - ./frontend:/app + - /app/node_modules + depends_on: + - backend + backend: + build: + context: ./backend + dockerfile: dev.Dockerfile + container_name: elements-backend-dev + ports: + - 3001:5102 + volumes: + - ./backend/elements-backend.sln:/app/elements-backend.sln + - ./backend/Elements.Data:/app/Elements.Data + - ./backend/Elements.Backend:/app/Elements.Backend + - /app/Elements.Backend/obj + - /app/Elements.Backend/bin + - /app/Elements.Data/obj + - /app/Elements.Data/bin + depends_on: + database: + condition: service_healthy + database: + image: postgres:latest + container_name: elements-database-dev + restart: always + volumes: + - db-data:/var/lib/postgresql/data + ports: + - 3002:5432 + environment: + POSTGRES_USER: elements + POSTGRES_PASSWORD: elementspass + healthcheck: + test: ["CMD-SHELL", "pg_isready -U elements"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + db-data:
\ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..02ed34a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3.8' +services: + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + ports: + - 3000:80 + depends_on: + - backend + backend: + build: + context: ./backend + dockerfile: Dockerfile + ports: + - 3001:80 + depends_on: + database: + condition: service_healthy + database: + image: postgres:latest + restart: always + volumes: + - db-data:/var/lib/postgresql/data + environment: + POSTGRES_USER: elements + POSTGRES_PASSWORD: elementspass + healthcheck: + test: ["CMD-SHELL", "pg_isready -U elements"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + db-data:
\ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..0b93a16 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,25 @@ +FROM node:21-alpine as builder + +WORKDIR /app + +COPY package.json ./ +COPY package-lock.json ./ +COPY src ./src/ +COPY index.html ./ +COPY public ./ +COPY .env ./ +COPY postcss.config.js ./ +COPY tailwind.config.js ./ +COPY tsconfig.json ./ +COPY tsconfig.node.json ./ +COPY vite.config.ts ./ + +RUN npm ci +RUN npm run build + +FROM nginx:latest + +WORKDIR /app + +COPY --from=builder /app/dist ./ +COPY ./nginx.conf /etc/nginx/conf.d/default.conf
\ No newline at end of file diff --git a/frontend/dev.Dockerfile b/frontend/dev.Dockerfile new file mode 100644 index 0000000..3afc332 --- /dev/null +++ b/frontend/dev.Dockerfile @@ -0,0 +1,9 @@ +FROM node:21-alpine + +WORKDIR /app + +COPY package.json ./ +COPY package-lock.json ./ + +RUN npm install +CMD ["npm", "run", "dev"]
\ No newline at end of file diff --git a/frontend/nginx.conf b/frontend/nginx.conf new file mode 100644 index 0000000..6599254 --- /dev/null +++ b/frontend/nginx.conf @@ -0,0 +1,12 @@ +server { + listen 80; + location / { + root /app; + try_files $uri /index.html; + } + + location /api { + rewrite /api(.*) $1 break; + proxy_pass http://backend; + } +}
\ No newline at end of file diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index dd8afab..e24c640 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -4,9 +4,11 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ server: { + port: 80, + host: true, proxy: { '/api': { - target: 'http://localhost:5102', + target: 'http://backend:5102/', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), } |
