diff --git a/ClubService.API/Controller/AdminController.cs b/ClubService.API/Controller/AdminController.cs index 8a46773..13b16e2 100644 --- a/ClubService.API/Controller/AdminController.cs +++ b/ClubService.API/Controller/AdminController.cs @@ -25,6 +25,7 @@ public class AdminController( [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] [Authorize(Roles = "ADMIN")] public async Task> RegisterAdmin( [FromBody] AdminRegisterCommand adminRegisterCommand) @@ -57,6 +58,7 @@ public async Task> DeleteAdmin(Guid id) [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] [Authorize(Roles = "ADMIN")] public async Task> UpdateAdmin(Guid id, [FromBody] AdminUpdateCommand adminUpdateCommand) { diff --git a/ClubService.API/Controller/MemberController.cs b/ClubService.API/Controller/MemberController.cs index bb80971..42ec15b 100644 --- a/ClubService.API/Controller/MemberController.cs +++ b/ClubService.API/Controller/MemberController.cs @@ -55,6 +55,7 @@ public async Task> GetMemberById(Guid id) [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] [Authorize(Roles = "ADMIN")] public async Task> RegisterMember([FromBody] MemberRegisterCommand memberRegisterCommand) { @@ -73,8 +74,9 @@ public async Task> RegisterMember([FromBody] MemberRegisterCo [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] [Authorize(Roles = "MEMBER")] - public async Task> UpdateMember(Guid id, MemberUpdateCommand memberUpdateCommand) + public async Task> UpdateMember(Guid id, [FromBody] MemberUpdateCommand memberUpdateCommand) { var jwtUserId = User.Claims.FirstOrDefault(c => c.Type == "sub")?.Value; diff --git a/ClubService.API/Controller/TennisClubController.cs b/ClubService.API/Controller/TennisClubController.cs index 55aa6c0..3b640e4 100644 --- a/ClubService.API/Controller/TennisClubController.cs +++ b/ClubService.API/Controller/TennisClubController.cs @@ -113,6 +113,7 @@ public async Task>> GetMembersByTennisClubId( [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] public async Task> RegisterTennisClub( [FromBody] TennisClubRegisterCommand tennisClubRegisterCommand) { @@ -127,6 +128,7 @@ public async Task> RegisterTennisClub( [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] [Authorize(Roles = "ADMIN")] public async Task> UpdateTennisClub( Guid id, diff --git a/ClubService.API/Controller/UserController.cs b/ClubService.API/Controller/UserController.cs index d70462e..6adee8f 100644 --- a/ClubService.API/Controller/UserController.cs +++ b/ClubService.API/Controller/UserController.cs @@ -18,6 +18,7 @@ public class UserController(ILoginService loginService, IUserService userService [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] public async Task> Login( [FromBody] LoginCommand loginCommand) { @@ -32,6 +33,7 @@ public async Task> Login( [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Consumes("application/json")] [Authorize(Roles = "SYSTEM_OPERATOR,ADMIN,MEMBER")] public async Task ChangePassword([FromBody] ChangePasswordCommand changePasswordCommand) { diff --git a/ClubService.API/Program.cs b/ClubService.API/Program.cs index 83b2df7..6935919 100644 --- a/ClubService.API/Program.cs +++ b/ClubService.API/Program.cs @@ -47,17 +47,17 @@ { if (eventStoreDbContext.Database.GetPendingMigrations().Any()) { - eventStoreDbContext.Database.Migrate(); + await eventStoreDbContext.Database.MigrateAsync(); } if (readStoreDbContext.Database.GetPendingMigrations().Any()) { - readStoreDbContext.Database.Migrate(); + await readStoreDbContext.Database.MigrateAsync(); } if (loginStoreDbContext.Database.GetPendingMigrations().Any()) { - loginStoreDbContext.Database.Migrate(); + await loginStoreDbContext.Database.MigrateAsync(); } } else if (app.Environment.IsDevelopment() || app.Environment.IsEnvironment("DockerDevelopment")) diff --git a/ClubService.Infrastructure/ClubService.Infrastructure.csproj b/ClubService.Infrastructure/ClubService.Infrastructure.csproj index 1f3c4f7..d6a186f 100644 --- a/ClubService.Infrastructure/ClubService.Infrastructure.csproj +++ b/ClubService.Infrastructure/ClubService.Infrastructure.csproj @@ -33,7 +33,9 @@ + + diff --git a/ClubService.Infrastructure/DbContexts/EventStoreDbContext.cs b/ClubService.Infrastructure/DbContexts/EventStoreDbContext.cs index e0f5c6b..3bb4fb6 100644 --- a/ClubService.Infrastructure/DbContexts/EventStoreDbContext.cs +++ b/ClubService.Infrastructure/DbContexts/EventStoreDbContext.cs @@ -36,40 +36,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) DateTime.UtcNow, new SystemOperatorRegisteredEvent( new SystemOperatorId(new Guid("1588ec27-c932-4dee-a341-d18c8108a711")), "systemoperator") - ) - ); - } - - public async Task SeedTestData() - { - // We need to seed the test data like this so that the events are inserted in the right order into the db - // With HasData the order is not the same like in the code and then debezium fetches the events in the wrong order - var domainEvents = new List> - { - // Subscription Tiers - new( - new Guid("8d4d3eff-b77b-4e21-963b-e211366bb94b"), - new Guid("38888969-d579-46ec-9cd6-0208569a077e"), - EventType.SUBSCRIPTION_TIER_CREATED, - EntityType.SUBSCRIPTION_TIER, - DateTime.UtcNow, - new SubscriptionTierCreatedEvent( - new SubscriptionTierId(new Guid("38888969-d579-46ec-9cd6-0208569a077e")), - "Gorilla Subscription Tier", - 200) - ), - new( - new Guid("e335d85a-f844-4c7e-b608-035ef00af733"), - new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7"), - EventType.SUBSCRIPTION_TIER_CREATED, - EntityType.SUBSCRIPTION_TIER, - DateTime.UtcNow, - new SubscriptionTierCreatedEvent( - new SubscriptionTierId(new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7")), - "Bison Subscription Tier", - 250) ), - new( + + // Subscription Tiers + new DomainEnvelope( new Guid("36db98d7-8fea-4715-923c-74192b147752"), new Guid("4c148d45-ebc8-4bbf-aa9a-d491eb185ad5"), EventType.SUBSCRIPTION_TIER_CREATED, @@ -80,7 +50,7 @@ public async Task SeedTestData() "Guinea Pig Subscription Tier", 100) ), - new( + new DomainEnvelope( new Guid("3b591696-d9c9-4e30-a6a1-6a1439c5580b"), new Guid("2bebd11c-bf8e-4448-886f-0cb8608af7ca"), EventType.SUBSCRIPTION_TIER_CREATED, @@ -91,7 +61,37 @@ public async Task SeedTestData() "Woolf Subscription Tier", 150) ), + new DomainEnvelope( + new Guid("8d4d3eff-b77b-4e21-963b-e211366bb94b"), + new Guid("38888969-d579-46ec-9cd6-0208569a077e"), + EventType.SUBSCRIPTION_TIER_CREATED, + EntityType.SUBSCRIPTION_TIER, + DateTime.UtcNow, + new SubscriptionTierCreatedEvent( + new SubscriptionTierId(new Guid("38888969-d579-46ec-9cd6-0208569a077e")), + "Gorilla Subscription Tier", + 200) + ), + new DomainEnvelope( + new Guid("e335d85a-f844-4c7e-b608-035ef00af733"), + new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7"), + EventType.SUBSCRIPTION_TIER_CREATED, + EntityType.SUBSCRIPTION_TIER, + DateTime.UtcNow, + new SubscriptionTierCreatedEvent( + new SubscriptionTierId(new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7")), + "Bison Subscription Tier", + 250) + ) + ); + } + public async Task SeedTestData() + { + // We need to seed the test data like this so that the events are inserted in the right order into the db + // With HasData the order is not the same as in the code and then debezium fetches the events in the wrong order + var domainEvents = new List> + { // Tennis Clubs new( new Guid("049af565-a42d-4f02-b213-793459e4873f"), diff --git a/ClubService.Infrastructure/Migrations/EventStore/20240704170701_InitialEventStore.Designer.cs b/ClubService.Infrastructure/Migrations/EventStore/20240704170701_InitialEventStore.Designer.cs deleted file mode 100644 index 0b05bac..0000000 --- a/ClubService.Infrastructure/Migrations/EventStore/20240704170701_InitialEventStore.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -// - -#nullable disable - -using ClubService.Infrastructure.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace ClubService.Infrastructure.Migrations.EventStore -{ - [DbContext(typeof(EventStoreDbContext))] - [Migration("20240704170701_InitialEventStore")] - partial class InitialEventStore - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("ClubService.Domain.Event.DomainEnvelope", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("eventId"); - - b.Property("EntityId") - .HasColumnType("uuid") - .HasColumnName("entityId"); - - b.Property("EntityType") - .IsRequired() - .HasColumnType("text") - .HasColumnName("entityType"); - - b.Property("EventData") - .HasColumnType("text") - .HasColumnName("eventData"); - - b.Property("EventType") - .IsRequired() - .HasColumnType("text") - .HasColumnName("eventType"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("timestamp"); - - b.HasKey("EventId") - .HasName("pK_DomainEvent"); - - b.ToTable("DomainEvent", (string)null); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ClubService.Infrastructure/Migrations/EventStore/20240704170701_InitialEventStore.cs b/ClubService.Infrastructure/Migrations/EventStore/20240704170701_InitialEventStore.cs deleted file mode 100644 index e0a16cb..0000000 --- a/ClubService.Infrastructure/Migrations/EventStore/20240704170701_InitialEventStore.cs +++ /dev/null @@ -1,34 +0,0 @@ -#nullable disable - -using Microsoft.EntityFrameworkCore.Migrations; - -namespace ClubService.Infrastructure.Migrations.EventStore -{ - /// - public partial class InitialEventStore : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DomainEvent", - columns: table => new - { - eventId = table.Column(type: "uuid", nullable: false), - entityId = table.Column(type: "uuid", nullable: false), - eventType = table.Column(type: "text", nullable: false), - entityType = table.Column(type: "text", nullable: false), - timestamp = table.Column(type: "timestamp with time zone", nullable: false), - eventData = table.Column(type: "text", nullable: true) - }, - constraints: table => { table.PrimaryKey("pK_DomainEvent", x => x.eventId); }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DomainEvent"); - } - } -} \ No newline at end of file diff --git a/ClubService.Infrastructure/Migrations/EventStore/20240709210357_InitialEventStore.Designer.cs b/ClubService.Infrastructure/Migrations/EventStore/20240709210357_InitialEventStore.Designer.cs new file mode 100644 index 0000000..c75dd9c --- /dev/null +++ b/ClubService.Infrastructure/Migrations/EventStore/20240709210357_InitialEventStore.Designer.cs @@ -0,0 +1,112 @@ +// +using System; +using ClubService.Infrastructure.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ClubService.Infrastructure.Migrations.EventStore +{ + [DbContext(typeof(EventStoreDbContext))] + [Migration("20240709210357_InitialEventStore")] + partial class InitialEventStore + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("ClubService.Domain.Event.DomainEnvelope", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("eventId"); + + b.Property("EntityId") + .HasColumnType("uuid") + .HasColumnName("entityId"); + + b.Property("EntityType") + .IsRequired() + .HasColumnType("text") + .HasColumnName("entityType"); + + b.Property("EventData") + .HasColumnType("text") + .HasColumnName("eventData"); + + b.Property("EventType") + .IsRequired() + .HasColumnType("text") + .HasColumnName("eventType"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("timestamp"); + + b.HasKey("EventId") + .HasName("pK_DomainEvent"); + + b.ToTable("DomainEvent", (string)null); + + b.HasData( + new + { + EventId = new Guid("ba4eeaa4-9707-4da0-8ee2-3684b4f7804f"), + EntityId = new Guid("1588ec27-c932-4dee-a341-d18c8108a711"), + EntityType = "SYSTEM_OPERATOR", + EventData = "{\"SystemOperatorId\":{\"Id\":\"1588ec27-c932-4dee-a341-d18c8108a711\"},\"Username\":\"systemoperator\"}", + EventType = "SYSTEM_OPERATOR_REGISTERED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7907) + }, + new + { + EventId = new Guid("36db98d7-8fea-4715-923c-74192b147752"), + EntityId = new Guid("4c148d45-ebc8-4bbf-aa9a-d491eb185ad5"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"4c148d45-ebc8-4bbf-aa9a-d491eb185ad5\"},\"Name\":\"Guinea Pig Subscription Tier\",\"MaxMemberCount\":100}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7913) + }, + new + { + EventId = new Guid("3b591696-d9c9-4e30-a6a1-6a1439c5580b"), + EntityId = new Guid("2bebd11c-bf8e-4448-886f-0cb8608af7ca"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"2bebd11c-bf8e-4448-886f-0cb8608af7ca\"},\"Name\":\"Woolf Subscription Tier\",\"MaxMemberCount\":150}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7916) + }, + new + { + EventId = new Guid("8d4d3eff-b77b-4e21-963b-e211366bb94b"), + EntityId = new Guid("38888969-d579-46ec-9cd6-0208569a077e"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"38888969-d579-46ec-9cd6-0208569a077e\"},\"Name\":\"Gorilla Subscription Tier\",\"MaxMemberCount\":200}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7918) + }, + new + { + EventId = new Guid("e335d85a-f844-4c7e-b608-035ef00af733"), + EntityId = new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"d19073ba-f760-4a9a-abfa-f8215d96bec7\"},\"Name\":\"Bison Subscription Tier\",\"MaxMemberCount\":250}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7921) + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ClubService.Infrastructure/Migrations/EventStore/20240709210357_InitialEventStore.cs b/ClubService.Infrastructure/Migrations/EventStore/20240709210357_InitialEventStore.cs new file mode 100644 index 0000000..df94065 --- /dev/null +++ b/ClubService.Infrastructure/Migrations/EventStore/20240709210357_InitialEventStore.cs @@ -0,0 +1,52 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace ClubService.Infrastructure.Migrations.EventStore +{ + /// + public partial class InitialEventStore : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DomainEvent", + columns: table => new + { + eventId = table.Column(type: "uuid", nullable: false), + entityId = table.Column(type: "uuid", nullable: false), + eventType = table.Column(type: "text", nullable: false), + entityType = table.Column(type: "text", nullable: false), + timestamp = table.Column(type: "timestamp with time zone", nullable: false), + eventData = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pK_DomainEvent", x => x.eventId); + }); + + migrationBuilder.InsertData( + table: "DomainEvent", + columns: new[] { "eventId", "entityId", "entityType", "eventData", "eventType", "timestamp" }, + values: new object[,] + { + { new Guid("36db98d7-8fea-4715-923c-74192b147752"), new Guid("4c148d45-ebc8-4bbf-aa9a-d491eb185ad5"), "SUBSCRIPTION_TIER", "{\"Id\":{\"Id\":\"4c148d45-ebc8-4bbf-aa9a-d491eb185ad5\"},\"Name\":\"Guinea Pig Subscription Tier\",\"MaxMemberCount\":100}", "SUBSCRIPTION_TIER_CREATED", new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7913) }, + { new Guid("3b591696-d9c9-4e30-a6a1-6a1439c5580b"), new Guid("2bebd11c-bf8e-4448-886f-0cb8608af7ca"), "SUBSCRIPTION_TIER", "{\"Id\":{\"Id\":\"2bebd11c-bf8e-4448-886f-0cb8608af7ca\"},\"Name\":\"Woolf Subscription Tier\",\"MaxMemberCount\":150}", "SUBSCRIPTION_TIER_CREATED", new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7916) }, + { new Guid("8d4d3eff-b77b-4e21-963b-e211366bb94b"), new Guid("38888969-d579-46ec-9cd6-0208569a077e"), "SUBSCRIPTION_TIER", "{\"Id\":{\"Id\":\"38888969-d579-46ec-9cd6-0208569a077e\"},\"Name\":\"Gorilla Subscription Tier\",\"MaxMemberCount\":200}", "SUBSCRIPTION_TIER_CREATED", new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7918) }, + { new Guid("ba4eeaa4-9707-4da0-8ee2-3684b4f7804f"), new Guid("1588ec27-c932-4dee-a341-d18c8108a711"), "SYSTEM_OPERATOR", "{\"SystemOperatorId\":{\"Id\":\"1588ec27-c932-4dee-a341-d18c8108a711\"},\"Username\":\"systemoperator\"}", "SYSTEM_OPERATOR_REGISTERED", new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7907) }, + { new Guid("e335d85a-f844-4c7e-b608-035ef00af733"), new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7"), "SUBSCRIPTION_TIER", "{\"Id\":{\"Id\":\"d19073ba-f760-4a9a-abfa-f8215d96bec7\"},\"Name\":\"Bison Subscription Tier\",\"MaxMemberCount\":250}", "SUBSCRIPTION_TIER_CREATED", new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7921) } + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DomainEvent"); + } + } +} diff --git a/ClubService.Infrastructure/Migrations/EventStore/EventStoreDbContextModelSnapshot.cs b/ClubService.Infrastructure/Migrations/EventStore/EventStoreDbContextModelSnapshot.cs index 21f74f0..875ab68 100644 --- a/ClubService.Infrastructure/Migrations/EventStore/EventStoreDbContextModelSnapshot.cs +++ b/ClubService.Infrastructure/Migrations/EventStore/EventStoreDbContextModelSnapshot.cs @@ -55,6 +55,53 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasName("pK_DomainEvent"); b.ToTable("DomainEvent", (string)null); + + b.HasData( + new + { + EventId = new Guid("ba4eeaa4-9707-4da0-8ee2-3684b4f7804f"), + EntityId = new Guid("1588ec27-c932-4dee-a341-d18c8108a711"), + EntityType = "SYSTEM_OPERATOR", + EventData = "{\"SystemOperatorId\":{\"Id\":\"1588ec27-c932-4dee-a341-d18c8108a711\"},\"Username\":\"systemoperator\"}", + EventType = "SYSTEM_OPERATOR_REGISTERED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7907) + }, + new + { + EventId = new Guid("36db98d7-8fea-4715-923c-74192b147752"), + EntityId = new Guid("4c148d45-ebc8-4bbf-aa9a-d491eb185ad5"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"4c148d45-ebc8-4bbf-aa9a-d491eb185ad5\"},\"Name\":\"Guinea Pig Subscription Tier\",\"MaxMemberCount\":100}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7913) + }, + new + { + EventId = new Guid("3b591696-d9c9-4e30-a6a1-6a1439c5580b"), + EntityId = new Guid("2bebd11c-bf8e-4448-886f-0cb8608af7ca"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"2bebd11c-bf8e-4448-886f-0cb8608af7ca\"},\"Name\":\"Woolf Subscription Tier\",\"MaxMemberCount\":150}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7916) + }, + new + { + EventId = new Guid("8d4d3eff-b77b-4e21-963b-e211366bb94b"), + EntityId = new Guid("38888969-d579-46ec-9cd6-0208569a077e"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"38888969-d579-46ec-9cd6-0208569a077e\"},\"Name\":\"Gorilla Subscription Tier\",\"MaxMemberCount\":200}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7918) + }, + new + { + EventId = new Guid("e335d85a-f844-4c7e-b608-035ef00af733"), + EntityId = new Guid("d19073ba-f760-4a9a-abfa-f8215d96bec7"), + EntityType = "SUBSCRIPTION_TIER", + EventData = "{\"Id\":{\"Id\":\"d19073ba-f760-4a9a-abfa-f8215d96bec7\"},\"Name\":\"Bison Subscription Tier\",\"MaxMemberCount\":250}", + EventType = "SUBSCRIPTION_TIER_CREATED", + Timestamp = new DateTime(2024, 7, 9, 21, 3, 56, 835, DateTimeKind.Utc).AddTicks(7921) + }); }); #pragma warning restore 612, 618 } diff --git a/ClubService.Infrastructure/Migrations/LoginStore/20240704171249_InitialLoginStore.Designer.cs b/ClubService.Infrastructure/Migrations/LoginStore/20240704171249_InitialLoginStore.Designer.cs deleted file mode 100644 index 8b0e8d7..0000000 --- a/ClubService.Infrastructure/Migrations/LoginStore/20240704171249_InitialLoginStore.Designer.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -using System; -using ClubService.Infrastructure.DbContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace ClubService.Infrastructure.Migrations.LoginStore -{ - [DbContext(typeof(LoginStoreDbContext))] - [Migration("20240704171249_InitialLoginStore")] - partial class InitialLoginStore - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("ClubService.Domain.Model.Entity.UserPassword", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("userId"); - - b.Property("HashedPassword") - .IsRequired() - .HasColumnType("text") - .HasColumnName("hashedPassword"); - - b.HasKey("UserId") - .HasName("pK_UserPassword"); - - b.ToTable("UserPassword", (string)null); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ClubService.Infrastructure/Migrations/LoginStore/20240709210524_InitialLoginStore.Designer.cs b/ClubService.Infrastructure/Migrations/LoginStore/20240709210524_InitialLoginStore.Designer.cs new file mode 100644 index 0000000..d36a487 --- /dev/null +++ b/ClubService.Infrastructure/Migrations/LoginStore/20240709210524_InitialLoginStore.Designer.cs @@ -0,0 +1,84 @@ +// +using System; +using ClubService.Infrastructure.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ClubService.Infrastructure.Migrations.LoginStore +{ + [DbContext(typeof(LoginStoreDbContext))] + [Migration("20240709210524_InitialLoginStore")] + partial class InitialLoginStore + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("ClubService.Domain.Model.Entity.UserPassword", b => + { + b.Property("UserId") + .HasColumnType("uuid") + .HasColumnName("userId"); + + b.Property("HashedPassword") + .IsRequired() + .HasColumnType("text") + .HasColumnName("hashedPassword"); + + b.HasKey("UserId") + .HasName("pK_UserPassword"); + + b.ToTable("UserPassword", (string)null); + + b.HasData( + new + { + UserId = new Guid("1588ec27-c932-4dee-a341-d18c8108a711"), + HashedPassword = "AQAAAAIAAYagAAAAEDUKJ7ReV2uEyekYGEB91VvXGmWH+HwRO9wfUHnqgb5QHs0NJTac+/OUJbiInt64zg==" + }, + new + { + UserId = new Guid("1dd88382-f781-4bf8-94e3-05e99d1434fe"), + HashedPassword = "AQAAAAIAAYagAAAAEINUWsPuMng880Mae+aQWYsWtBOozyrGRXjlwTzpZhgI5IAbm0g+JoI0kDdPkrKBfA==" + }, + new + { + UserId = new Guid("4a2eb3dc-7f1e-4dac-851a-667594ca31ff"), + HashedPassword = "AQAAAAIAAYagAAAAEBKu/YIpt3bJSChT1BW8kziF2PcNfbYrn/ar4ApIvo9CCoTypAWnJaWV4SsNTfTaYg==" + }, + new + { + UserId = new Guid("5d2f1aec-1cc6-440a-b04f-ba8b3085a35a"), + HashedPassword = "AQAAAAIAAYagAAAAEGT6tP27VLg6Fj8DqqMkzoXM1u5ZPMFlx9QJY4c/aBb3jGng1ySWdmC7l3w6hknQCw==" + }, + new + { + UserId = new Guid("60831440-06d2-4017-9a7b-016e9cd0b2dc"), + HashedPassword = "AQAAAAIAAYagAAAAEOHyHLp7O2x6x+SSomU58BNU/B3SwbkVe1iW8mI3kJCbx/3ltTcee3VNfC6O8xpOrQ==" + }, + new + { + UserId = new Guid("51ae7aca-2bb8-421a-a923-2ba2eb94bb3a"), + HashedPassword = "AQAAAAIAAYagAAAAEINyI26mDpfR+H5XGY+1zwGWGqT5+1jkHC9rxFDUNC3xcTlFyf9en7A64cfrLmhQ7Q==" + }, + new + { + UserId = new Guid("e8a2cd4c-69ad-4cf2-bca6-a60d88be6649"), + HashedPassword = "AQAAAAIAAYagAAAAEAWIvUbmCZPblT7HngkrZ1f4zfBtO8WGDd4SScg1ZZPE7SlytGjjxbLI1hPm0DePjw==" + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ClubService.Infrastructure/Migrations/LoginStore/20240704171249_InitialLoginStore.cs b/ClubService.Infrastructure/Migrations/LoginStore/20240709210524_InitialLoginStore.cs similarity index 56% rename from ClubService.Infrastructure/Migrations/LoginStore/20240704171249_InitialLoginStore.cs rename to ClubService.Infrastructure/Migrations/LoginStore/20240709210524_InitialLoginStore.cs index 052624c..1677e94 100644 --- a/ClubService.Infrastructure/Migrations/LoginStore/20240704171249_InitialLoginStore.cs +++ b/ClubService.Infrastructure/Migrations/LoginStore/20240709210524_InitialLoginStore.cs @@ -1,7 +1,10 @@ -#nullable disable - +using System; using Microsoft.EntityFrameworkCore.Migrations; +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + namespace ClubService.Infrastructure.Migrations.LoginStore { /// @@ -17,7 +20,18 @@ protected override void Up(MigrationBuilder migrationBuilder) userId = table.Column(type: "uuid", nullable: false), hashedPassword = table.Column(type: "text", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_UserPassword", x => x.userId); }); + constraints: table => + { + table.PrimaryKey("pK_UserPassword", x => x.userId); + }); + + migrationBuilder.InsertData( + table: "UserPassword", + columns: new[] { "userId", "hashedPassword" }, + values: new object[,] + { + { new Guid("1588ec27-c932-4dee-a341-d18c8108a711"), "AQAAAAIAAYagAAAAEDUKJ7ReV2uEyekYGEB91VvXGmWH+HwRO9wfUHnqgb5QHs0NJTac+/OUJbiInt64zg==" } + }); } /// @@ -27,4 +41,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "UserPassword"); } } -} \ No newline at end of file +} diff --git a/ClubService.Infrastructure/Migrations/LoginStore/LoginStoreDbContextModelSnapshot.cs b/ClubService.Infrastructure/Migrations/LoginStore/LoginStoreDbContextModelSnapshot.cs index 80d64e5..8f4e41d 100644 --- a/ClubService.Infrastructure/Migrations/LoginStore/LoginStoreDbContextModelSnapshot.cs +++ b/ClubService.Infrastructure/Migrations/LoginStore/LoginStoreDbContextModelSnapshot.cs @@ -37,6 +37,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasName("pK_UserPassword"); b.ToTable("UserPassword", (string)null); + + b.HasData( + new + { + UserId = new Guid("1588ec27-c932-4dee-a341-d18c8108a711"), + HashedPassword = "AQAAAAIAAYagAAAAEDUKJ7ReV2uEyekYGEB91VvXGmWH+HwRO9wfUHnqgb5QHs0NJTac+/OUJbiInt64zg==" + }); }); #pragma warning restore 612, 618 } diff --git a/ClubService.Infrastructure/Migrations/ReadStore/20240704170935_InitialReadStore.Designer.cs b/ClubService.Infrastructure/Migrations/ReadStore/20240709210752_InitialReadStore.Designer.cs similarity index 92% rename from ClubService.Infrastructure/Migrations/ReadStore/20240704170935_InitialReadStore.Designer.cs rename to ClubService.Infrastructure/Migrations/ReadStore/20240709210752_InitialReadStore.Designer.cs index f336473..cb08360 100644 --- a/ClubService.Infrastructure/Migrations/ReadStore/20240704170935_InitialReadStore.Designer.cs +++ b/ClubService.Infrastructure/Migrations/ReadStore/20240709210752_InitialReadStore.Designer.cs @@ -1,16 +1,18 @@ // - -#nullable disable - +using System; using ClubService.Infrastructure.DbContexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable namespace ClubService.Infrastructure.Migrations.ReadStore { [DbContext(typeof(ReadStoreDbContext))] - [Migration("20240704170935_InitialReadStore")] + [Migration("20240709210752_InitialReadStore")] partial class InitialReadStore { /// @@ -142,6 +144,23 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("SubscriptionTier", (string)null); }); + modelBuilder.Entity("ClubService.Domain.ReadModel.SystemOperatorReadModel", b => + { + b.Property("SystemOperatorId") + .HasColumnType("uuid") + .HasColumnName("systemOperatorId"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text") + .HasColumnName("username"); + + b.HasKey("SystemOperatorId") + .HasName("pK_SystemOperator"); + + b.ToTable("SystemOperator", (string)null); + }); + modelBuilder.Entity("ClubService.Domain.ReadModel.TennisClubReadModel", b => { b.Property("TennisClubId") diff --git a/ClubService.Infrastructure/Migrations/ReadStore/20240704170935_InitialReadStore.cs b/ClubService.Infrastructure/Migrations/ReadStore/20240709210752_InitialReadStore.cs similarity index 74% rename from ClubService.Infrastructure/Migrations/ReadStore/20240704170935_InitialReadStore.cs rename to ClubService.Infrastructure/Migrations/ReadStore/20240709210752_InitialReadStore.cs index 7109f44..13e91a2 100644 --- a/ClubService.Infrastructure/Migrations/ReadStore/20240704170935_InitialReadStore.cs +++ b/ClubService.Infrastructure/Migrations/ReadStore/20240709210752_InitialReadStore.cs @@ -1,7 +1,8 @@ -#nullable disable - +using System; using Microsoft.EntityFrameworkCore.Migrations; +#nullable disable + namespace ClubService.Infrastructure.Migrations.ReadStore { /// @@ -21,7 +22,10 @@ protected override void Up(MigrationBuilder migrationBuilder) tennisClubId = table.Column(type: "uuid", nullable: false), status = table.Column(type: "text", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_Admin", x => x.adminId); }); + constraints: table => + { + table.PrimaryKey("pK_Admin", x => x.adminId); + }); migrationBuilder.CreateTable( name: "EmailOutbox", @@ -33,7 +37,10 @@ protected override void Up(MigrationBuilder migrationBuilder) body = table.Column(type: "text", nullable: false), timestamp = table.Column(type: "timestamp with time zone", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_EmailOutbox", x => x.id); }); + constraints: table => + { + table.PrimaryKey("pK_EmailOutbox", x => x.id); + }); migrationBuilder.CreateTable( name: "Member", @@ -46,7 +53,10 @@ protected override void Up(MigrationBuilder migrationBuilder) tennisClubId = table.Column(type: "uuid", nullable: false), status = table.Column(type: "text", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_Member", x => x.memberId); }); + constraints: table => + { + table.PrimaryKey("pK_Member", x => x.memberId); + }); migrationBuilder.CreateTable( name: "ProcessedEvent", @@ -54,7 +64,10 @@ protected override void Up(MigrationBuilder migrationBuilder) { eventId = table.Column(type: "uuid", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_ProcessedEvent", x => x.eventId); }); + constraints: table => + { + table.PrimaryKey("pK_ProcessedEvent", x => x.eventId); + }); migrationBuilder.CreateTable( name: "SubscriptionTier", @@ -64,7 +77,22 @@ protected override void Up(MigrationBuilder migrationBuilder) name = table.Column(type: "text", nullable: false), maxMemberCount = table.Column(type: "integer", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_SubscriptionTier", x => x.subscriptionTierId); }); + constraints: table => + { + table.PrimaryKey("pK_SubscriptionTier", x => x.subscriptionTierId); + }); + + migrationBuilder.CreateTable( + name: "SystemOperator", + columns: table => new + { + systemOperatorId = table.Column(type: "uuid", nullable: false), + username = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pK_SystemOperator", x => x.systemOperatorId); + }); migrationBuilder.CreateTable( name: "TennisClub", @@ -76,7 +104,10 @@ protected override void Up(MigrationBuilder migrationBuilder) status = table.Column(type: "text", nullable: false), memberCount = table.Column(type: "integer", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_TennisClub", x => x.tennisClubId); }); + constraints: table => + { + table.PrimaryKey("pK_TennisClub", x => x.tennisClubId); + }); migrationBuilder.CreateTable( name: "Tournament", @@ -88,7 +119,10 @@ protected override void Up(MigrationBuilder migrationBuilder) startDate = table.Column(type: "date", nullable: false), endDate = table.Column(type: "date", nullable: false) }, - constraints: table => { table.PrimaryKey("pK_Tournament", x => x.tournamentId); }); + constraints: table => + { + table.PrimaryKey("pK_Tournament", x => x.tournamentId); + }); } /// @@ -109,6 +143,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "SubscriptionTier"); + migrationBuilder.DropTable( + name: "SystemOperator"); + migrationBuilder.DropTable( name: "TennisClub"); @@ -116,4 +153,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Tournament"); } } -} \ No newline at end of file +} diff --git a/ClubService.Infrastructure/Migrations/ReadStore/ReadStoreDbContextModelSnapshot.cs b/ClubService.Infrastructure/Migrations/ReadStore/ReadStoreDbContextModelSnapshot.cs index 5492e2d..583c685 100644 --- a/ClubService.Infrastructure/Migrations/ReadStore/ReadStoreDbContextModelSnapshot.cs +++ b/ClubService.Infrastructure/Migrations/ReadStore/ReadStoreDbContextModelSnapshot.cs @@ -141,6 +141,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("SubscriptionTier", (string)null); }); + modelBuilder.Entity("ClubService.Domain.ReadModel.SystemOperatorReadModel", b => + { + b.Property("SystemOperatorId") + .HasColumnType("uuid") + .HasColumnName("systemOperatorId"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text") + .HasColumnName("username"); + + b.HasKey("SystemOperatorId") + .HasName("pK_SystemOperator"); + + b.ToTable("SystemOperator", (string)null); + }); + modelBuilder.Entity("ClubService.Domain.ReadModel.TennisClubReadModel", b => { b.Property("TennisClubId")