diff --git a/db/query_statistics.sql b/db/query_statistics.sql index bc1d94c..762eb75 100644 --- a/db/query_statistics.sql +++ b/db/query_statistics.sql @@ -1,11 +1,11 @@ SELECT customer.customername AS customer, - TO_CHAR(appointment."yearMonth", 'Month YYYY') AS month, + TO_CHAR(appointment."yearmonth", 'Month YYYY') AS month, appointment.count AS appointments, participant.count AS participants, voting.count AS votings -FROM "appointmentStatistic" appointment - LEFT JOIN "participantStatistic" participant ON appointment."customerId" = participant."customerId" - LEFT JOIN "votingStatistic" voting ON appointment."customerId" = voting."customerId" - LEFT JOIN customer ON appointment."customerId" = customer.customerid -WHERE appointment."customerId" = '11111111-1111-1111-1111-111111111111' -ORDER BY appointment."yearMonth" DESC; \ No newline at end of file +FROM "appointmentstatistic" appointment + LEFT JOIN "participantstatistic" participant ON appointment."customerid" = participant."customerid" + LEFT JOIN "votingstatistic" voting ON appointment."customerid" = voting."customerid" + LEFT JOIN customer ON appointment."customerid" = customer.customerid +WHERE appointment."customerid" = '11111111-1111-1111-1111-111111111111' +ORDER BY appointment."yearmonth" DESC; \ No newline at end of file diff --git a/src/Dataport.Terminfinder.BusinessObject/AppointmentStatistic.cs b/src/Dataport.Terminfinder.BusinessObject/AppointmentStatistic.cs index 3121995..7b0080b 100644 --- a/src/Dataport.Terminfinder.BusinessObject/AppointmentStatistic.cs +++ b/src/Dataport.Terminfinder.BusinessObject/AppointmentStatistic.cs @@ -4,13 +4,13 @@ /// Representation for an appointment statistic /// [ExcludeFromCodeCoverage] -[Table("appointmentStatistic", Schema = "public")] +[Table("appointmentstatistic", Schema = "public")] public class AppointmentStatistic { /// /// Identifier of the appointment statistic /// - [Column("appointmentStatisticId")] + [Column("appointmentstatisticid")] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid AppointmentStatisticId { get; set; } @@ -18,13 +18,13 @@ public class AppointmentStatistic /// Identifier of the customer /// /// 00000000-0000-0000-0000-000000000000 - [Column("customerId")] + [Column("customerid")] public Guid CustomerId { get; set; } /// /// The year and month for which the statistic is recorded /// - [Column("yearMonth")] + [Column("yearmonth")] public DateOnly YearMonth { get; set; } /// diff --git a/src/Dataport.Terminfinder.BusinessObject/ParticipantStatistic.cs b/src/Dataport.Terminfinder.BusinessObject/ParticipantStatistic.cs index e11e5e0..db8f6ea 100644 --- a/src/Dataport.Terminfinder.BusinessObject/ParticipantStatistic.cs +++ b/src/Dataport.Terminfinder.BusinessObject/ParticipantStatistic.cs @@ -4,13 +4,13 @@ /// Representation for a Participant statistic /// [ExcludeFromCodeCoverage] -[Table("participantStatistic", Schema = "public")] +[Table("participantstatistic", Schema = "public")] public class ParticipantStatistic { /// /// Identifier of the participant statistic /// - [Column("participantStatisticId")] + [Column("participantstatisticid")] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid ParticipantStatisticId { get; set; } @@ -18,13 +18,13 @@ public class ParticipantStatistic /// Identifier of the customer /// /// 00000000-0000-0000-0000-000000000000 - [Column("customerId")] + [Column("customerid")] public Guid CustomerId { get; set; } /// /// The year and month for which the statistic is recorded /// - [Column("yearMonth")] + [Column("yearmonth")] public DateOnly YearMonth { get; set; } /// diff --git a/src/Dataport.Terminfinder.BusinessObject/VotingStatistic.cs b/src/Dataport.Terminfinder.BusinessObject/VotingStatistic.cs index fc34351..bd85195 100644 --- a/src/Dataport.Terminfinder.BusinessObject/VotingStatistic.cs +++ b/src/Dataport.Terminfinder.BusinessObject/VotingStatistic.cs @@ -4,13 +4,13 @@ /// Representation for a Voting statistic /// [ExcludeFromCodeCoverage] -[Table("votingStatistic", Schema = "public")] +[Table("votingstatistic", Schema = "public")] public class VotingStatistic { /// /// Identifier of the voting statistic /// - [Column("votingStatisticId")] + [Column("votingstatisticid")] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid VotingStatisticId { get; set; } @@ -18,13 +18,13 @@ public class VotingStatistic /// Identifier of the customer /// /// 00000000-0000-0000-0000-000000000000 - [Column("customerId")] + [Column("customerid")] public Guid CustomerId { get; set; } /// /// The year and month for which the statistic is recorded /// - [Column("yearMonth")] + [Column("yearmonth")] public DateOnly YearMonth { get; set; } /// diff --git a/src/Dataport.Terminfinder.Repository/Migrations/20260909113548_AddStatistics.Designer.cs b/src/Dataport.Terminfinder.Repository/Migrations/20260917102723_AddStatistics.Designer.cs similarity index 96% rename from src/Dataport.Terminfinder.Repository/Migrations/20260909113548_AddStatistics.Designer.cs rename to src/Dataport.Terminfinder.Repository/Migrations/20260917102723_AddStatistics.Designer.cs index 25b21f1..a776528 100644 --- a/src/Dataport.Terminfinder.Repository/Migrations/20260909113548_AddStatistics.Designer.cs +++ b/src/Dataport.Terminfinder.Repository/Migrations/20260917102723_AddStatistics.Designer.cs @@ -12,7 +12,7 @@ namespace Dataport.Terminfinder.Repository.Migrations { [DbContext(typeof(DataContext))] - [Migration("20260909113548_AddStatistics")] + [Migration("20260917102723_AddStatistics")] partial class AddStatistics { /// @@ -116,7 +116,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AppointmentStatisticId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasColumnName("appointmentStatisticId"); + .HasColumnName("appointmentstatisticid"); b.Property("Count") .ValueGeneratedOnAdd() @@ -126,18 +126,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("CustomerId") .HasColumnType("uuid") - .HasColumnName("customerId"); + .HasColumnName("customerid"); b.Property("YearMonth") .HasColumnType("date") - .HasColumnName("yearMonth"); + .HasColumnName("yearmonth"); b.HasKey("AppointmentStatisticId"); b.HasIndex("CustomerId", "YearMonth") .IsUnique(); - b.ToTable("appointmentStatistic", "public"); + b.ToTable("appointmentstatistic", "public"); }); modelBuilder.Entity("Dataport.Terminfinder.BusinessObject.Customer", b => @@ -215,7 +215,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ParticipantStatisticId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasColumnName("participantStatisticId"); + .HasColumnName("participantstatisticid"); b.Property("Count") .ValueGeneratedOnAdd() @@ -225,18 +225,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("CustomerId") .HasColumnType("uuid") - .HasColumnName("customerId"); + .HasColumnName("customerid"); b.Property("YearMonth") .HasColumnType("date") - .HasColumnName("yearMonth"); + .HasColumnName("yearmonth"); b.HasKey("ParticipantStatisticId"); b.HasIndex("CustomerId", "YearMonth") .IsUnique(); - b.ToTable("participantStatistic", "public"); + b.ToTable("participantstatistic", "public"); }); modelBuilder.Entity("Dataport.Terminfinder.BusinessObject.SuggestedDate", b => @@ -357,7 +357,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("VotingStatisticId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasColumnName("votingStatisticId"); + .HasColumnName("votingstatisticid"); b.Property("Count") .ValueGeneratedOnAdd() @@ -367,18 +367,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("CustomerId") .HasColumnType("uuid") - .HasColumnName("customerId"); + .HasColumnName("customerid"); b.Property("YearMonth") .HasColumnType("date") - .HasColumnName("yearMonth"); + .HasColumnName("yearmonth"); b.HasKey("VotingStatisticId"); b.HasIndex("CustomerId", "YearMonth") .IsUnique(); - b.ToTable("votingStatistic", "public"); + b.ToTable("votingstatistic", "public"); }); modelBuilder.Entity("Dataport.Terminfinder.BusinessObject.Appointment", b => diff --git a/src/Dataport.Terminfinder.Repository/Migrations/20260909113548_AddStatistics.cs b/src/Dataport.Terminfinder.Repository/Migrations/20260917102723_AddStatistics.cs similarity index 62% rename from src/Dataport.Terminfinder.Repository/Migrations/20260909113548_AddStatistics.cs rename to src/Dataport.Terminfinder.Repository/Migrations/20260917102723_AddStatistics.cs index d94c633..d3f9621 100644 --- a/src/Dataport.Terminfinder.Repository/Migrations/20260909113548_AddStatistics.cs +++ b/src/Dataport.Terminfinder.Repository/Migrations/20260917102723_AddStatistics.cs @@ -13,76 +13,76 @@ public partial class AddStatistics : Migration /// protected override void Up(MigrationBuilder migrationBuilder) { - var sqlInhalt = "update public.appconfig set configvalue='1.4.0' WHERE configkey='version';"; + var sqlInhalt = "update public.appconfig set configvalue='1.4.1' WHERE configkey='version';"; migrationBuilder.Sql(sqlInhalt, suppressTransaction: true); - sqlInhalt = "update public.appconfig set configvalue='2026-09-09' WHERE configkey='builddate';"; + sqlInhalt = "update public.appconfig set configvalue='2026-09-17' WHERE configkey='builddate';"; migrationBuilder.Sql(sqlInhalt, suppressTransaction: true); migrationBuilder.CreateTable( - name: "appointmentStatistic", + name: "appointmentstatistic", schema: "public", columns: table => new { - appointmentStatisticId = table.Column(type: "uuid", nullable: false), - customerId = table.Column(type: "uuid", nullable: false), - yearMonth = table.Column(type: "date", nullable: false), + appointmentstatisticid = table.Column(type: "uuid", nullable: false), + customerid = table.Column(type: "uuid", nullable: false), + yearmonth = table.Column(type: "date", nullable: false), count = table.Column(type: "integer", nullable: false, defaultValue: 1) }, constraints: table => { - table.PrimaryKey("PK_appointmentStatistic", x => x.appointmentStatisticId); + table.PrimaryKey("PK_appointmentstatistic", x => x.appointmentstatisticid); }); migrationBuilder.CreateTable( - name: "participantStatistic", + name: "participantstatistic", schema: "public", columns: table => new { - participantStatisticId = table.Column(type: "uuid", nullable: false), - customerId = table.Column(type: "uuid", nullable: false), - yearMonth = table.Column(type: "date", nullable: false), + participantstatisticid = table.Column(type: "uuid", nullable: false), + customerid = table.Column(type: "uuid", nullable: false), + yearmonth = table.Column(type: "date", nullable: false), count = table.Column(type: "integer", nullable: false, defaultValue: 1) }, constraints: table => { - table.PrimaryKey("PK_participantStatistic", x => x.participantStatisticId); + table.PrimaryKey("PK_participantstatistic", x => x.participantstatisticid); }); migrationBuilder.CreateTable( - name: "votingStatistic", + name: "votingstatistic", schema: "public", columns: table => new { - votingStatisticId = table.Column(type: "uuid", nullable: false), - customerId = table.Column(type: "uuid", nullable: false), - yearMonth = table.Column(type: "date", nullable: false), + votingstatisticid = table.Column(type: "uuid", nullable: false), + customerid = table.Column(type: "uuid", nullable: false), + yearmonth = table.Column(type: "date", nullable: false), count = table.Column(type: "integer", nullable: false, defaultValue: 1) }, constraints: table => { - table.PrimaryKey("PK_votingStatistic", x => x.votingStatisticId); + table.PrimaryKey("PK_votingstatistic", x => x.votingstatisticid); }); migrationBuilder.CreateIndex( - name: "IX_appointmentStatistic_customerId_yearMonth", + name: "IX_appointmentstatistic_customerid_yearmonth", schema: "public", - table: "appointmentStatistic", - columns: new[] { "customerId", "yearMonth" }, + table: "appointmentstatistic", + columns: new[] { "customerid", "yearmonth" }, unique: true); migrationBuilder.CreateIndex( - name: "IX_participantStatistic_customerId_yearMonth", + name: "IX_participantstatistic_customerid_yearmonth", schema: "public", - table: "participantStatistic", - columns: new[] { "customerId", "yearMonth" }, + table: "participantstatistic", + columns: new[] { "customerid", "yearmonth" }, unique: true); migrationBuilder.CreateIndex( - name: "IX_votingStatistic_customerId_yearMonth", + name: "IX_votingstatistic_customerid_yearmonth", schema: "public", - table: "votingStatistic", - columns: new[] { "customerId", "yearMonth" }, + table: "votingstatistic", + columns: new[] { "customerid", "yearmonth" }, unique: true); } @@ -96,15 +96,15 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.Sql(sqlInhalt, suppressTransaction: true); migrationBuilder.DropTable( - name: "appointmentStatistic", + name: "appointmentstatistic", schema: "public"); migrationBuilder.DropTable( - name: "participantStatistic", + name: "participantstatistic", schema: "public"); migrationBuilder.DropTable( - name: "votingStatistic", + name: "votingstatistic", schema: "public"); } } diff --git a/src/Dataport.Terminfinder.Repository/Migrations/DataContextModelSnapshot.cs b/src/Dataport.Terminfinder.Repository/Migrations/DataContextModelSnapshot.cs index 93a57de..9fe04c9 100644 --- a/src/Dataport.Terminfinder.Repository/Migrations/DataContextModelSnapshot.cs +++ b/src/Dataport.Terminfinder.Repository/Migrations/DataContextModelSnapshot.cs @@ -115,7 +115,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AppointmentStatisticId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasColumnName("appointmentStatisticId"); + .HasColumnName("appointmentstatisticid"); b.Property("Count") .ValueGeneratedOnAdd() @@ -125,18 +125,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CustomerId") .HasColumnType("uuid") - .HasColumnName("customerId"); + .HasColumnName("customerid"); b.Property("YearMonth") .HasColumnType("date") - .HasColumnName("yearMonth"); + .HasColumnName("yearmonth"); b.HasKey("AppointmentStatisticId"); b.HasIndex("CustomerId", "YearMonth") .IsUnique(); - b.ToTable("appointmentStatistic", "public"); + b.ToTable("appointmentstatistic", "public"); }); modelBuilder.Entity("Dataport.Terminfinder.BusinessObject.Customer", b => @@ -214,7 +214,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ParticipantStatisticId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasColumnName("participantStatisticId"); + .HasColumnName("participantstatisticid"); b.Property("Count") .ValueGeneratedOnAdd() @@ -224,18 +224,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CustomerId") .HasColumnType("uuid") - .HasColumnName("customerId"); + .HasColumnName("customerid"); b.Property("YearMonth") .HasColumnType("date") - .HasColumnName("yearMonth"); + .HasColumnName("yearmonth"); b.HasKey("ParticipantStatisticId"); b.HasIndex("CustomerId", "YearMonth") .IsUnique(); - b.ToTable("participantStatistic", "public"); + b.ToTable("participantstatistic", "public"); }); modelBuilder.Entity("Dataport.Terminfinder.BusinessObject.SuggestedDate", b => @@ -356,7 +356,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("VotingStatisticId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasColumnName("votingStatisticId"); + .HasColumnName("votingstatisticid"); b.Property("Count") .ValueGeneratedOnAdd() @@ -366,18 +366,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CustomerId") .HasColumnType("uuid") - .HasColumnName("customerId"); + .HasColumnName("customerid"); b.Property("YearMonth") .HasColumnType("date") - .HasColumnName("yearMonth"); + .HasColumnName("yearmonth"); b.HasKey("VotingStatisticId"); b.HasIndex("CustomerId", "YearMonth") .IsUnique(); - b.ToTable("votingStatistic", "public"); + b.ToTable("votingstatistic", "public"); }); modelBuilder.Entity("Dataport.Terminfinder.BusinessObject.Appointment", b => diff --git a/src/Dataport.Terminfinder.Repository/README.md b/src/Dataport.Terminfinder.Repository/README.md index e900fdb..ec94221 100644 --- a/src/Dataport.Terminfinder.Repository/README.md +++ b/src/Dataport.Terminfinder.Repository/README.md @@ -1,5 +1,7 @@ # Repository +Use `dotnet tool update --global dotnet-ef` to update the global tools to the latest available version. + ## Add Migration Navigate to the directory `Dataport.Terminfinder.Repository` @@ -8,4 +10,11 @@ Navigate to the directory `Dataport.Terminfinder.Repository` dotnet-ef migrations add --startup-project ../Dataport.Terminfinder.WebAPI ``` -Use `dotnet tool update --global dotnet-ef` to update the global tools to the latest available version. +### Generate SQL File from existing Migration + +The file is created from an existing migration to another. If you want to include everything, set `MIGRATIONID_FROM` +to `0`. The MigrationId is a combination of the timestamp and the migration name, e.g. `20260917102723_AddStatistics`. + +```bash +dotnet-ef migrations script --idempotent -o --startup-project ../Dataport.Terminfinder.WebAPI --context DataContext +``` \ No newline at end of file