From 36001d8d9dc61612cd0cd33a52ebd4cc1414333b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 4 Dec 2024 13:30:31 +0100 Subject: [PATCH 1/7] Update everything to .NET 9 (and to newest packages) --- backend/.config/dotnet-tools.json | 8 +-- backend/Directory.Build.props | 2 +- backend/Directory.Packages.props | 64 +++++++++---------- backend/Jenkinsfile | 2 +- backend/dev/Dockerfile.api | 2 +- backend/dev/Dockerfile.integration_tests | 2 +- backend/dev/Dockerfile.leanpipe_funnel | 2 +- backend/dev/Dockerfile.migrations | 2 +- backend/dev/Dockerfile.tests | 2 +- backend/release/Dockerfile.api | 2 +- backend/release/Dockerfile.migrations | 2 +- .../DataAccess/ExamplesDbContext.cs | 9 --- ...46_AddServiceProvidersAndTheirCalendars.cs | 2 +- .../20241024100702_AddReservations.cs | 2 +- .../ExampleApp.Examples.csproj | 4 -- .../HttpContextExtensions.cs | 6 ++ .../Examples/ExampleApp.Examples/Startup.cs | 2 + 17 files changed, 51 insertions(+), 64 deletions(-) diff --git a/backend/.config/dotnet-tools.json b/backend/.config/dotnet-tools.json index 59764f17..f98a08da 100644 --- a/backend/.config/dotnet-tools.json +++ b/backend/.config/dotnet-tools.json @@ -9,17 +9,11 @@ ] }, "dotnet-ef": { - "version": "8.0.8", + "version": "9.0.0", "commands": [ "dotnet-ef" ] }, - "dotnet-format": { - "version": "5.1.250801", - "commands": [ - "dotnet-format" - ] - }, "dotnet-contracts-generate": { "version": "3.0.0", "commands": [ diff --git a/backend/Directory.Build.props b/backend/Directory.Build.props index afa6a302..6925e097 100644 --- a/backend/Directory.Build.props +++ b/backend/Directory.Build.props @@ -11,7 +11,7 @@ $(AssemblyName) $(AssemblyName) - net8.0 + net9.0 enable enable preview diff --git a/backend/Directory.Packages.props b/backend/Directory.Packages.props index 59e25a62..51b57824 100644 --- a/backend/Directory.Packages.props +++ b/backend/Directory.Packages.props @@ -1,16 +1,17 @@ true - - 8.1.2527 - 8.0.1 - 8.0.8 - 8.0.8 - 8.2.5 - 8.0.3 - 8.0.4 - 0.2.5 - 1.0.46 + true + + 9.0.2542-preview + 9.0.0 + 9.0.0 + 9.0.0 + 8.3.2 + 9.0.1 + 9.0.1 + 0.3.0 + 2.0.52 @@ -62,23 +63,23 @@ - + - + - + - + @@ -96,44 +97,41 @@ - - - + + - + - - + + - - + - - + + - + - - - - - - - - + + + + + + + diff --git a/backend/Jenkinsfile b/backend/Jenkinsfile index 2b9f511c..b4fe2420 100644 --- a/backend/Jenkinsfile +++ b/backend/Jenkinsfile @@ -6,7 +6,7 @@ def dbPassword = 'Passw12#' leancode.builder('exampleapp-backend') .withMonorepoTest(['backend']) .withBuildKit() - .withDotnet([version: '8.0', image: 'mcr.microsoft.com/dotnet/sdk']) + .withDotnet([version: '9.0', image: 'mcr.microsoft.com/dotnet/sdk']) .withDefaultContainer( name: 'postgres', image: 'postgres', diff --git a/backend/dev/Dockerfile.api b/backend/dev/Dockerfile.api index 77bf7e51..2f717ea1 100644 --- a/backend/dev/Dockerfile.api +++ b/backend/dev/Dockerfile.api @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 +FROM mcr.microsoft.com/dotnet/sdk:9.0 USER root diff --git a/backend/dev/Dockerfile.integration_tests b/backend/dev/Dockerfile.integration_tests index 0d42db5a..d4101af6 100644 --- a/backend/dev/Dockerfile.integration_tests +++ b/backend/dev/Dockerfile.integration_tests @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 +FROM mcr.microsoft.com/dotnet/sdk:9.0 USER root diff --git a/backend/dev/Dockerfile.leanpipe_funnel b/backend/dev/Dockerfile.leanpipe_funnel index 052413f9..68abec32 100644 --- a/backend/dev/Dockerfile.leanpipe_funnel +++ b/backend/dev/Dockerfile.leanpipe_funnel @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 +FROM mcr.microsoft.com/dotnet/sdk:9.0 USER root diff --git a/backend/dev/Dockerfile.migrations b/backend/dev/Dockerfile.migrations index 8b87d756..00ce46f2 100644 --- a/backend/dev/Dockerfile.migrations +++ b/backend/dev/Dockerfile.migrations @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 USER $APP_UID diff --git a/backend/dev/Dockerfile.tests b/backend/dev/Dockerfile.tests index ae3d0b98..ed8d83a6 100644 --- a/backend/dev/Dockerfile.tests +++ b/backend/dev/Dockerfile.tests @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 +FROM mcr.microsoft.com/dotnet/sdk:9.0 USER root diff --git a/backend/release/Dockerfile.api b/backend/release/Dockerfile.api index fa18b29c..9d0681be 100644 --- a/backend/release/Dockerfile.api +++ b/backend/release/Dockerfile.api @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 USER $APP_UID diff --git a/backend/release/Dockerfile.migrations b/backend/release/Dockerfile.migrations index 44a15886..d82010d6 100644 --- a/backend/release/Dockerfile.migrations +++ b/backend/release/Dockerfile.migrations @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 USER $APP_UID diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/ExamplesDbContext.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/ExamplesDbContext.cs index 71706aa4..906b7d8b 100644 --- a/backend/src/Examples/ExampleApp.Examples/DataAccess/ExamplesDbContext.cs +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/ExamplesDbContext.cs @@ -14,15 +14,6 @@ public ExamplesDbContext(DbContextOptions options) protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) { - //-:cnd:noEmit -#if CHECK_EFCORE_PG_2977 -#error Check if this workaround is still required. -#else - // workaround for https://github.com/npgsql/efcore.pg/issues/2977 - configurationBuilder.Properties().HaveColumnType("jsonb"); -#endif - //+:cnd:noEmit - #if Example ConfigureExampleAppConventions(configurationBuilder); #endif diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241008201246_AddServiceProvidersAndTheirCalendars.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241008201246_AddServiceProvidersAndTheirCalendars.cs index c96b9502..341a4864 100644 --- a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241008201246_AddServiceProvidersAndTheirCalendars.cs +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241008201246_AddServiceProvidersAndTheirCalendars.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241024100702_AddReservations.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241024100702_AddReservations.cs index b71b23ca..2e993e55 100644 --- a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241024100702_AddReservations.cs +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241024100702_AddReservations.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj b/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj index 4e1bb90e..91f3623e 100644 --- a/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj +++ b/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj @@ -1,10 +1,6 @@ - - $(DefineConstants);CHECK_EFCORE_PG_2977 - - Exe ExampleApp.Examples diff --git a/backend/src/Examples/ExampleApp.Examples/HttpContextExtensions.cs b/backend/src/Examples/ExampleApp.Examples/HttpContextExtensions.cs index 4aeed1f6..10688750 100644 --- a/backend/src/Examples/ExampleApp.Examples/HttpContextExtensions.cs +++ b/backend/src/Examples/ExampleApp.Examples/HttpContextExtensions.cs @@ -18,6 +18,12 @@ public static Guid GetUserId(this HttpContext context) return Guid.Parse(claim); } + public static bool TryGetUserId(this HttpContext context, out Guid userId) + { + var claim = context.User.FindFirstValue(Auth.KnownClaims.UserId); + return Guid.TryParse(claim, out userId); + } + #if Example public static CustomerId GetCustomerId(this HttpContext context) { diff --git a/backend/src/Examples/ExampleApp.Examples/Startup.cs b/backend/src/Examples/ExampleApp.Examples/Startup.cs index 51b07034..860e4ce9 100644 --- a/backend/src/Examples/ExampleApp.Examples/Startup.cs +++ b/backend/src/Examples/ExampleApp.Examples/Startup.cs @@ -496,5 +496,7 @@ public static void AliasScoped(this IServiceCollectio public sealed class UserIdExtractor : IUserIdExtractor { public Guid Extract(HttpContext httpContext) => httpContext.GetUserId(); + + public bool TryExtract(HttpContext httpContext, out Guid userId) => httpContext.TryGetUserId(out userId); } #endif From dbc9c2fe5e004a1cbc6b7f750178e0fe3cbe621d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 4 Dec 2024 13:34:07 +0100 Subject: [PATCH 2/7] Update CSharpier --- backend/.config/dotnet-tools.json | 11 ++- .../EventSerializationTests.Data.cs | 77 +++++++++---------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/backend/.config/dotnet-tools.json b/backend/.config/dotnet-tools.json index f98a08da..e3ddf5a1 100644 --- a/backend/.config/dotnet-tools.json +++ b/backend/.config/dotnet-tools.json @@ -3,22 +3,25 @@ "isRoot": true, "tools": { "csharpier": { - "version": "0.29.2", + "version": "0.30.2", "commands": [ "dotnet-csharpier" - ] + ], + "rollForward": false }, "dotnet-ef": { "version": "9.0.0", "commands": [ "dotnet-ef" - ] + ], + "rollForward": false }, "dotnet-contracts-generate": { "version": "3.0.0", "commands": [ "dotnet-contracts-generate" - ] + ], + "rollForward": false } } } \ No newline at end of file diff --git a/backend/tests/Examples/ExampleApp.Examples.Tests/EventSerializationTests.Data.cs b/backend/tests/Examples/ExampleApp.Examples.Tests/EventSerializationTests.Data.cs index d7b69a52..11380fc4 100644 --- a/backend/tests/Examples/ExampleApp.Examples.Tests/EventSerializationTests.Data.cs +++ b/backend/tests/Examples/ExampleApp.Examples.Tests/EventSerializationTests.Data.cs @@ -23,45 +23,44 @@ public partial class EventSerializationTests #endif private static readonly Guid Guid = Guid.NewGuid(); private static readonly DateTime DateTime = DateTime.UtcNow; - private static readonly Identity KratosIdentity = - new() - { - State = IdentityState.Active, - CreatedAt = DateTime, - Id = Guid, - RecoveryAddresses = - [ - new() - { - CreatedAt = DateTime, - Id = Guid, - UpdatedAt = DateTime, - Value = "test@leancode.pl", - Via = AddressType.Email, - }, - ], - SchemaId = "user", - SchemaUrl = new("https://auth.exampleapp.test.lncd.pl/schemas/dXNlcg"), - StateChangedAt = DateTime, - UpdatedAt = DateTime, - VerifiableAddresses = - [ - new() - { - CreatedAt = DateTime, - Id = Guid, - Status = AddressStatus.Completed, - UpdatedAt = DateTime, - Value = "test@leancode.pl", - Verified = true, - VerifiedAt = DateTime, - Via = AddressType.Email, - }, - ], - MetadataAdmin = JsonSerializer.Deserialize(@"{""foo"":""bar""}"), - MetadataPublic = JsonSerializer.Deserialize(@"{""roles"":[""user""]}"), - Traits = JsonSerializer.Deserialize(@"{""email"":""test@leancode.pl""}"), - }; + private static readonly Identity KratosIdentity = new() + { + State = IdentityState.Active, + CreatedAt = DateTime, + Id = Guid, + RecoveryAddresses = + [ + new() + { + CreatedAt = DateTime, + Id = Guid, + UpdatedAt = DateTime, + Value = "test@leancode.pl", + Via = AddressType.Email, + }, + ], + SchemaId = "user", + SchemaUrl = new("https://auth.exampleapp.test.lncd.pl/schemas/dXNlcg"), + StateChangedAt = DateTime, + UpdatedAt = DateTime, + VerifiableAddresses = + [ + new() + { + CreatedAt = DateTime, + Id = Guid, + Status = AddressStatus.Completed, + UpdatedAt = DateTime, + Value = "test@leancode.pl", + Verified = true, + VerifiedAt = DateTime, + Via = AddressType.Email, + }, + ], + MetadataAdmin = JsonSerializer.Deserialize(@"{""foo"":""bar""}"), + MetadataPublic = JsonSerializer.Deserialize(@"{""roles"":[""user""]}"), + Traits = JsonSerializer.Deserialize(@"{""email"":""test@leancode.pl""}"), + }; private static readonly ImmutableArray Events = [ From cc8ed9ab054938cec1810d174a1a2b241132452b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 4 Dec 2024 13:34:46 +0100 Subject: [PATCH 3/7] Update .NET version in template build --- Jenkinsfile.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.template b/Jenkinsfile.template index db506cdd..9848fd38 100644 --- a/Jenkinsfile.template +++ b/Jenkinsfile.template @@ -1,6 +1,6 @@ leancode.builder('exampleapp-template') .withMonorepoTest(['backend', 'dev-cluster', 'infrastructure', '.template.config', 'FinalizeTemplate.proj', 'Jenkinsfile.template']) - .withDotnet([version: '8.0', image: 'mcr.microsoft.com/dotnet/sdk']) + .withDotnet([version: '9.0', image: 'mcr.microsoft.com/dotnet/sdk']) .runOnSpot() .run { From 4efc02972ab9c6eb31f9d43328136f14291af153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 4 Dec 2024 13:37:07 +0100 Subject: [PATCH 4/7] Fix the usage of `dotnet format` --- FinalizeTemplate.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FinalizeTemplate.proj b/FinalizeTemplate.proj index c545c7fd..51de16e1 100644 --- a/FinalizeTemplate.proj +++ b/FinalizeTemplate.proj @@ -3,7 +3,7 @@ - + From 867d052d845d3a7d616a96d7e24dada3cf0b70f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 4 Dec 2024 13:59:15 +0100 Subject: [PATCH 5/7] Generate missing migrations and fix tests --- ...20241204125821_UpdateAppRating.Designer.cs | 664 ++++++++++++++++++ .../20241204125821_UpdateAppRating.cs | 70 ++ .../ExamplesDbContextModelSnapshot.cs | 31 +- .../Dashboards/AssignmentEmployerEmbedQH.cs | 5 +- .../DbContextInitializer.cs | 14 +- .../Migrations/MigrationsTests.cs | 8 +- 6 files changed, 770 insertions(+), 22 deletions(-) create mode 100644 backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.Designer.cs create mode 100644 backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.cs diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.Designer.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.Designer.cs new file mode 100644 index 00000000..bad0303c --- /dev/null +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.Designer.cs @@ -0,0 +1,664 @@ +// +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Text.Json; +using ExampleApp.Examples.DataAccess; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ExampleApp.Examples.DataAccess.Migrations +{ + [DbContext(typeof(ExamplesDbContext))] + [Migration("20241204125821_UpdateAppRating")] + partial class UpdateAppRating + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "citext"); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("ExampleApp.Examples.DataAccess.Entities.KratosIdentity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("MetadataAdmin") + .HasColumnType("jsonb"); + + b.Property("MetadataPublic") + .HasColumnType("jsonb"); + + b.Property("SchemaId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Traits") + .HasColumnType("jsonb"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("xmin") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.ToTable("KratosIdentities"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Booking.CalendarDay", b => + { + b.Property("Id") + .HasColumnType("citext"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone") + .HasColumnName("DateModified"); + + b.Property("ServiceProviderId") + .IsRequired() + .HasColumnType("citext"); + + b.Property("xmin") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasAlternateKey("ServiceProviderId", "Date"); + + b.ToTable("CalendarDays"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Booking.Reservation", b => + { + b.Property("Id") + .HasColumnType("citext"); + + b.Property("CalendarDayId") + .IsRequired() + .HasColumnType("citext"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone") + .HasColumnName("DateModified"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TimeslotId") + .IsRequired() + .HasColumnType("citext"); + + b.Property("xmin") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId", "Status"); + + b.HasIndex("CustomerId", "TimeslotId"); + + b.ToTable("Reservations"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Booking.ServiceProvider", b => + { + b.Property("Id") + .HasColumnType("citext"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone") + .HasColumnName("DateModified"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPromotionActive") + .HasColumnType("boolean"); + + b.Property("ListItemPicture") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PromotionalBanner") + .IsRequired() + .HasColumnType("text"); + + b.Property("Ratings") + .HasColumnType("double precision"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("xmin") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.ComplexProperty>("Location", "ExampleApp.Examples.Domain.Booking.ServiceProvider.Location#Location", b1 => + { + b1.IsRequired(); + + b1.Property("Latitude") + .HasColumnType("double precision"); + + b1.Property("Longitude") + .HasColumnType("double precision"); + }); + + b.HasKey("Id"); + + b.ToTable("ServiceProviders"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Booking.Timeslot", b => + { + b.Property("Id") + .HasColumnType("citext"); + + b.Property("CalendarDayId") + .IsRequired() + .HasColumnType("citext"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("EndTime") + .HasColumnType("time without time zone"); + + b.Property("ReservedBy") + .HasColumnType("citext"); + + b.Property("ServiceProviderId") + .IsRequired() + .HasColumnType("citext"); + + b.Property("StartTime") + .HasColumnType("time without time zone"); + + b.ComplexProperty>("Price", "ExampleApp.Examples.Domain.Booking.Timeslot.Price#Money", b1 => + { + b1.IsRequired(); + + b1.Property("Currency") + .IsRequired() + .HasColumnType("text"); + + b1.Property("Value") + .HasColumnType("numeric"); + }); + + b.HasKey("Id"); + + b.HasIndex("CalendarDayId"); + + b.HasIndex("ServiceProviderId", "CalendarDayId", "Date", "StartTime"); + + b.ToTable("Timeslots"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Employees.Employee", b => + { + b.Property("Id") + .HasColumnType("citext"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone") + .HasColumnName("DateModified"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("xmin") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Projects.Project", b => + { + b.Property("Id") + .HasColumnType("citext"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone") + .HasColumnName("DateModified"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("xmin") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("LeanCode.AppRating.DataAccess.AppRating", b => + { + b.Property("Id") + .HasColumnType("uuid"); + + b.Property("AdditionalComment") + .HasColumnType("text"); + + b.Property("AppVersion") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property>("Metadata") + .HasColumnType("jsonb"); + + b.Property("Platform") + .HasColumnType("integer"); + + b.Property("Rating") + .HasColumnType("double precision"); + + b.Property("SystemVersion") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "DateCreated"); + + b.ToTable("AppRatings"); + }); + + modelBuilder.Entity("LeanCode.Firebase.FCM.PushNotificationTokenEntity", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("Token") + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("UserId", "Token"); + + b.HasIndex("Token") + .IsUnique(); + + b.ToTable("PushNotificationTokens"); + }); + + modelBuilder.Entity("MassTransit.EntityFrameworkCoreIntegration.InboxState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Consumed") + .HasColumnType("timestamp with time zone"); + + b.Property("ConsumerId") + .HasColumnType("uuid"); + + b.Property("Delivered") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpirationTime") + .HasColumnType("timestamp with time zone"); + + b.Property("LastSequenceNumber") + .HasColumnType("bigint"); + + b.Property("LockId") + .HasColumnType("uuid"); + + b.Property("MessageId") + .HasColumnType("uuid"); + + b.Property("ReceiveCount") + .HasColumnType("integer"); + + b.Property("Received") + .HasColumnType("timestamp with time zone"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Delivered"); + + b.ToTable("InboxState"); + }); + + modelBuilder.Entity("MassTransit.EntityFrameworkCoreIntegration.OutboxMessage", b => + { + b.Property("SequenceNumber") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SequenceNumber")); + + b.Property("Body") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("ConversationId") + .HasColumnType("uuid"); + + b.Property("CorrelationId") + .HasColumnType("uuid"); + + b.Property("DestinationAddress") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EnqueueTime") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpirationTime") + .HasColumnType("timestamp with time zone"); + + b.Property("FaultAddress") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Headers") + .HasColumnType("text"); + + b.Property("InboxConsumerId") + .HasColumnType("uuid"); + + b.Property("InboxMessageId") + .HasColumnType("uuid"); + + b.Property("InitiatorId") + .HasColumnType("uuid"); + + b.Property("MessageId") + .HasColumnType("uuid"); + + b.Property("MessageType") + .IsRequired() + .HasColumnType("text"); + + b.Property("OutboxId") + .HasColumnType("uuid"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("RequestId") + .HasColumnType("uuid"); + + b.Property("ResponseAddress") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("SentTime") + .HasColumnType("timestamp with time zone"); + + b.Property("SourceAddress") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("SequenceNumber"); + + b.HasIndex("EnqueueTime"); + + b.HasIndex("ExpirationTime"); + + b.HasIndex("OutboxId", "SequenceNumber") + .IsUnique(); + + b.HasIndex("InboxMessageId", "InboxConsumerId", "SequenceNumber") + .IsUnique(); + + b.ToTable("OutboxMessage"); + }); + + modelBuilder.Entity("MassTransit.EntityFrameworkCoreIntegration.OutboxState", b => + { + b.Property("OutboxId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Created") + .HasColumnType("timestamp with time zone"); + + b.Property("Delivered") + .HasColumnType("timestamp with time zone"); + + b.Property("LastSequenceNumber") + .HasColumnType("bigint"); + + b.Property("LockId") + .HasColumnType("uuid"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea"); + + b.HasKey("OutboxId"); + + b.HasIndex("Created"); + + b.ToTable("OutboxState"); + }); + + modelBuilder.Entity("ExampleApp.Examples.DataAccess.Entities.KratosIdentity", b => + { + b.OwnsMany("ExampleApp.Examples.DataAccess.Entities.KratosIdentityRecoveryAddress", "RecoveryAddresses", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b1.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b1.Property("IdentityId") + .HasColumnType("uuid"); + + b1.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b1.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b1.Property("Via") + .IsRequired() + .HasColumnType("text"); + + b1.HasKey("Id"); + + b1.HasIndex("IdentityId"); + + b1.ToTable("KratosIdentityRecoveryAddresses", (string)null); + + b1.WithOwner() + .HasForeignKey("IdentityId"); + }); + + b.OwnsMany("ExampleApp.Examples.DataAccess.Entities.KratosIdentityVerifiableAddress", "VerifiableAddresses", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b1.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b1.Property("IdentityId") + .HasColumnType("uuid"); + + b1.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b1.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b1.Property("VerifiedAt") + .HasColumnType("timestamp with time zone"); + + b1.Property("Via") + .IsRequired() + .HasColumnType("text"); + + b1.HasKey("Id"); + + b1.HasIndex("IdentityId"); + + b1.ToTable("KratosIdentityVerifiableAddresses", (string)null); + + b1.WithOwner() + .HasForeignKey("IdentityId"); + }); + + b.Navigation("RecoveryAddresses"); + + b.Navigation("VerifiableAddresses"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Booking.Timeslot", b => + { + b.HasOne("ExampleApp.Examples.Domain.Booking.CalendarDay", "CalendarDay") + .WithMany("Timeslots") + .HasForeignKey("CalendarDayId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CalendarDay"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Projects.Project", b => + { + b.OwnsMany("ExampleApp.Examples.Domain.Projects.Assignment", "Assignments", b1 => + { + b1.Property("ParentProjectId") + .HasColumnType("citext"); + + b1.Property("Id") + .HasColumnType("citext"); + + b1.Property("AssignedEmployeeId") + .HasColumnType("citext"); + + b1.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b1.Property("Status") + .HasColumnType("integer"); + + b1.HasKey("ParentProjectId", "Id"); + + b1.ToTable("Assignments", (string)null); + + b1.WithOwner("ParentProject") + .HasForeignKey("ParentProjectId"); + + b1.Navigation("ParentProject"); + }); + + b.Navigation("Assignments"); + }); + + modelBuilder.Entity("MassTransit.EntityFrameworkCoreIntegration.OutboxMessage", b => + { + b.HasOne("MassTransit.EntityFrameworkCoreIntegration.OutboxState", null) + .WithMany() + .HasForeignKey("OutboxId"); + + b.HasOne("MassTransit.EntityFrameworkCoreIntegration.InboxState", null) + .WithMany() + .HasForeignKey("InboxMessageId", "InboxConsumerId") + .HasPrincipalKey("MessageId", "ConsumerId"); + }); + + modelBuilder.Entity("ExampleApp.Examples.Domain.Booking.CalendarDay", b => + { + b.Navigation("Timeslots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.cs new file mode 100644 index 00000000..a899367e --- /dev/null +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.cs @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ExampleApp.Examples.DataAccess.Migrations; + +/// +public partial class UpdateAppRating : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey(name: "PK_AppRatings", table: "AppRatings"); + + migrationBuilder.AddColumn( + name: "Id", + table: "AppRatings", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000") + ); + + migrationBuilder.AddPrimaryKey(name: "PK_AppRatings", table: "AppRatings", column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_AppRatings_UserId_DateCreated", + table: "AppRatings", + columns: new[] { "UserId", "DateCreated" } + ); + + migrationBuilder.AddForeignKey( + name: "FK_OutboxMessage_InboxState_InboxMessageId_InboxConsumerId", + table: "OutboxMessage", + columns: new[] { "InboxMessageId", "InboxConsumerId" }, + principalTable: "InboxState", + principalColumns: new[] { "MessageId", "ConsumerId" } + ); + + migrationBuilder.AddForeignKey( + name: "FK_OutboxMessage_OutboxState_OutboxId", + table: "OutboxMessage", + column: "OutboxId", + principalTable: "OutboxState", + principalColumn: "OutboxId" + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_OutboxMessage_InboxState_InboxMessageId_InboxConsumerId", + table: "OutboxMessage" + ); + + migrationBuilder.DropForeignKey(name: "FK_OutboxMessage_OutboxState_OutboxId", table: "OutboxMessage"); + + migrationBuilder.DropPrimaryKey(name: "PK_AppRatings", table: "AppRatings"); + + migrationBuilder.DropIndex(name: "IX_AppRatings_UserId_DateCreated", table: "AppRatings"); + + migrationBuilder.DropColumn(name: "Id", table: "AppRatings"); + + migrationBuilder.AddPrimaryKey( + name: "PK_AppRatings", + table: "AppRatings", + columns: new[] { "UserId", "DateCreated" } + ); + } +} diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/ExamplesDbContextModelSnapshot.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/ExamplesDbContextModelSnapshot.cs index 660d2165..3c05bc2f 100644 --- a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/ExamplesDbContextModelSnapshot.cs +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/ExamplesDbContextModelSnapshot.cs @@ -20,7 +20,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("ProductVersion", "9.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "citext"); @@ -296,12 +296,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("LeanCode.AppRating.DataAccess.AppRating", b => { - b.Property("UserId") + b.Property("Id") .HasColumnType("uuid"); - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - b.Property("AdditionalComment") .HasColumnType("text"); @@ -309,6 +306,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("text"); + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + b.Property>("Metadata") .HasColumnType("jsonb"); @@ -322,7 +322,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("text"); - b.HasKey("UserId", "DateCreated"); + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "DateCreated"); b.ToTable("AppRatings"); }); @@ -388,8 +393,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasAlternateKey("MessageId", "ConsumerId"); - b.HasIndex("Delivered"); b.ToTable("InboxState"); @@ -636,6 +639,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Assignments"); }); + modelBuilder.Entity("MassTransit.EntityFrameworkCoreIntegration.OutboxMessage", b => + { + b.HasOne("MassTransit.EntityFrameworkCoreIntegration.OutboxState", null) + .WithMany() + .HasForeignKey("OutboxId"); + + b.HasOne("MassTransit.EntityFrameworkCoreIntegration.InboxState", null) + .WithMany() + .HasForeignKey("InboxMessageId", "InboxConsumerId") + .HasPrincipalKey("MessageId", "ConsumerId"); + }); + modelBuilder.Entity("ExampleApp.Examples.Domain.Booking.CalendarDay", b => { b.Navigation("Timeslots"); diff --git a/backend/src/Examples/ExampleApp.Examples/Handlers/Dashboards/AssignmentEmployerEmbedQH.cs b/backend/src/Examples/ExampleApp.Examples/Handlers/Dashboards/AssignmentEmployerEmbedQH.cs index 872cf64e..a40b9b3f 100644 --- a/backend/src/Examples/ExampleApp.Examples/Handlers/Dashboards/AssignmentEmployerEmbedQH.cs +++ b/backend/src/Examples/ExampleApp.Examples/Handlers/Dashboards/AssignmentEmployerEmbedQH.cs @@ -4,6 +4,7 @@ using LeanCode.CQRS.Execution; using LeanCode.TimeProvider; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.JsonWebTokens; using Microsoft.IdentityModel.Tokens; @@ -13,9 +14,9 @@ public class AssignmentEmployerEmbedQH : IQueryHandler config) { - this.config = config; + this.config = config.Value; } public Task ExecuteAsync(HttpContext context, AssignmentEmployerEmbed query) diff --git a/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/DbContextInitializer.cs b/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/DbContextInitializer.cs index 21173a6b..850910fa 100644 --- a/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/DbContextInitializer.cs +++ b/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/DbContextInitializer.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Npgsql; using Polly; @@ -6,7 +7,7 @@ namespace ExampleApp.Examples.IntegrationTests; -public class DbContextInitializer : IHostedService +public class DbContextInitializer(IServiceProvider serviceProvider) : IHostedService where T : DbContext { private static readonly IAsyncPolicy CreatePolicy = Policy @@ -15,15 +16,10 @@ public class DbContextInitializer : IHostedService private readonly ILogger logger = Log.ForContext>(); - private readonly T context; - - public DbContextInitializer(T context) - { - this.context = context; - } - public async Task StartAsync(CancellationToken cancellationToken) { + await using var scope = serviceProvider.CreateAsyncScope(); + await using var context = scope.ServiceProvider.GetRequiredService(); logger.Information("Creating database for context {ContextType}", context.GetType()); await CreatePolicy.ExecuteAsync( async (CancellationToken token) => @@ -51,6 +47,8 @@ await CreatePolicy.ExecuteAsync( public async Task StopAsync(CancellationToken cancellationToken) { + using var scope = serviceProvider.CreateAsyncScope(); + using var context = scope.ServiceProvider.GetRequiredService(); logger.Information("Dropping database for context {ContextType}", context.GetType()); // We skip the cancellation token to properly delete the database even if test fails await context.Database.EnsureDeletedAsync(CancellationToken.None); diff --git a/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/Migrations/MigrationsTests.cs b/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/Migrations/MigrationsTests.cs index 3a4368c4..0adf49b8 100644 --- a/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/Migrations/MigrationsTests.cs +++ b/backend/tests/Examples/ExampleApp.Examples.IntegrationTests/Migrations/MigrationsTests.cs @@ -17,8 +17,8 @@ public async Task Migrations_can_be_successfully_applied() await using var app = new ExampleAppTestApp { SkipDbContextInitialization = true }; await app.InitializeAsync(); - using var scope = app.Services.CreateScope(); - var dbContext = scope.ServiceProvider.GetRequiredService(); + await using var scope = app.Services.CreateAsyncScope(); + await using var dbContext = scope.ServiceProvider.GetRequiredService(); try { @@ -36,8 +36,8 @@ public async Task All_migrations_have_been_generated() await using var app = new ExampleAppTestApp { SkipDbContextInitialization = true }; await app.InitializeAsync(); - - var dbContext = app.Services.GetRequiredService(); + await using var scope = app.Services.CreateAsyncScope(); + await using var dbContext = scope.ServiceProvider.GetRequiredService(); var migrationsAssembly = dbContext.GetService(); var initializer = dbContext.GetService(); From 439871cccb25b155e616da60c6603335f8617cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 4 Dec 2024 15:43:23 +0100 Subject: [PATCH 6/7] Fix dependencies of dotnet ef bundle --- backend/Directory.Packages.props | 3 +++ .../ExampleApp.Examples/ExampleApp.Examples.csproj | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/backend/Directory.Packages.props b/backend/Directory.Packages.props index 51b57824..de7efb6b 100644 --- a/backend/Directory.Packages.props +++ b/backend/Directory.Packages.props @@ -130,8 +130,11 @@ + + + diff --git a/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj b/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj index 91f3623e..fc7aa0dc 100644 --- a/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj +++ b/backend/src/Examples/ExampleApp.Examples/ExampleApp.Examples.csproj @@ -78,4 +78,12 @@ + + + + + + + + From 840db2759a3d5397b18b42a0d34833c5da8e0205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Fija=C5=82kowski?= Date: Wed, 4 Dec 2024 15:55:22 +0100 Subject: [PATCH 7/7] Regenerate migrations with more appropriate name and set AppRatings.Id there --- ...s => 20241204145312_UpdateAppRatingsAndOutbox.Designer.cs} | 4 ++-- ...pRating.cs => 20241204145312_UpdateAppRatingsAndOutbox.cs} | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) rename backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/{20241204125821_UpdateAppRating.Designer.cs => 20241204145312_UpdateAppRatingsAndOutbox.Designer.cs} (99%) rename backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/{20241204125821_UpdateAppRating.cs => 20241204145312_UpdateAppRatingsAndOutbox.cs} (93%) diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.Designer.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204145312_UpdateAppRatingsAndOutbox.Designer.cs similarity index 99% rename from backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.Designer.cs rename to backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204145312_UpdateAppRatingsAndOutbox.Designer.cs index bad0303c..d7ff06f9 100644 --- a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.Designer.cs +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204145312_UpdateAppRatingsAndOutbox.Designer.cs @@ -15,8 +15,8 @@ namespace ExampleApp.Examples.DataAccess.Migrations { [DbContext(typeof(ExamplesDbContext))] - [Migration("20241204125821_UpdateAppRating")] - partial class UpdateAppRating + [Migration("20241204145312_UpdateAppRatingsAndOutbox")] + partial class UpdateAppRatingsAndOutbox { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.cs b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204145312_UpdateAppRatingsAndOutbox.cs similarity index 93% rename from backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.cs rename to backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204145312_UpdateAppRatingsAndOutbox.cs index a899367e..80fa6c1d 100644 --- a/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204125821_UpdateAppRating.cs +++ b/backend/src/Examples/ExampleApp.Examples/DataAccess/Migrations/20241204145312_UpdateAppRatingsAndOutbox.cs @@ -5,7 +5,7 @@ namespace ExampleApp.Examples.DataAccess.Migrations; /// -public partial class UpdateAppRating : Migration +public partial class UpdateAppRatingsAndOutbox : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -20,6 +20,8 @@ protected override void Up(MigrationBuilder migrationBuilder) defaultValue: new Guid("00000000-0000-0000-0000-000000000000") ); + migrationBuilder.Sql(@"update ""AppRatings"" set ""Id"" = gen_random_uuid();"); + migrationBuilder.AddPrimaryKey(name: "PK_AppRatings", table: "AppRatings", column: "Id"); migrationBuilder.CreateIndex(