diff --git a/src/FlightRecorder.Data/Migrations/20241201111608_MyFlightReport.Designer.cs b/src/FlightRecorder.Data/Migrations/20241201111608_MyFlightReport.Designer.cs new file mode 100644 index 0000000..9f94ecc --- /dev/null +++ b/src/FlightRecorder.Data/Migrations/20241201111608_MyFlightReport.Designer.cs @@ -0,0 +1,582 @@ +// +using System; +using FlightRecorder.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FlightRecorder.Data.Migrations +{ + [DbContext(typeof(FlightRecorderDbContext))] + [Migration("20241201111608_MyFlightReport")] + partial class MyFlightReport + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.0"); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Aircraft", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Manufactured") + .HasColumnType("INTEGER") + .HasColumnName("manufactured"); + + b.Property("ModelId") + .HasColumnType("INTEGER") + .HasColumnName("model_id"); + + b.Property("Registration") + .IsRequired() + .HasColumnType("VARCHAR(50)") + .HasColumnName("registration"); + + b.Property("SerialNumber") + .HasColumnType("VARCHAR(50)") + .HasColumnName("serial_number"); + + b.HasKey("Id"); + + b.HasIndex("ModelId"); + + b.ToTable("AIRCRAFT", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Airline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(100)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("AIRLINE", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Airport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("VARCHAR(5)") + .HasColumnName("code"); + + b.Property("CountryId") + .HasColumnType("INTEGER") + .HasColumnName("country_id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(100)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.HasIndex("CountryId"); + + b.ToTable("AIRPORT", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(50)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("COUNTRY", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Flight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("AirlineId") + .HasColumnType("INTEGER") + .HasColumnName("airline_id"); + + b.Property("Destination") + .IsRequired() + .HasColumnType("VARCHAR(3)") + .HasColumnName("destination"); + + b.Property("Embarkation") + .IsRequired() + .HasColumnType("VARCHAR(3)") + .HasColumnName("embarkation"); + + b.Property("Number") + .IsRequired() + .HasColumnType("VARCHAR(50)") + .HasColumnName("number"); + + b.HasKey("Id"); + + b.HasIndex("AirlineId"); + + b.ToTable("FLIGHT", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.JobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("End") + .HasColumnType("DATETIME") + .HasColumnName("end"); + + b.Property("Error") + .HasColumnType("TEXT") + .HasColumnName("error"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnName("name"); + + b.Property("Parameters") + .HasColumnType("TEXT") + .HasColumnName("parameters"); + + b.Property("Start") + .HasColumnType("DATETIME") + .HasColumnName("start"); + + b.HasKey("Id"); + + b.ToTable("JOB_STATUS", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(100)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("LOCATION", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Manufacturer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(100)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("MANUFACTURER", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Model", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("ManufacturerId") + .HasColumnType("INTEGER") + .HasColumnName("manufacturer_id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(100)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.HasIndex("ManufacturerId"); + + b.ToTable("MODEL", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Sighting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("AircraftId") + .HasColumnType("INTEGER") + .HasColumnName("aircraft_id"); + + b.Property("Altitude") + .HasColumnType("INTEGER") + .HasColumnName("altitude"); + + b.Property("Date") + .HasColumnType("DATETIME") + .HasColumnName("date"); + + b.Property("FlightId") + .HasColumnType("INTEGER") + .HasColumnName("flight_id"); + + b.Property("IsMyFlight") + .HasColumnType("INTEGER") + .HasColumnName("is_my_flight"); + + b.Property("LocationId") + .HasColumnType("INTEGER") + .HasColumnName("location_id"); + + b.HasKey("Id"); + + b.HasIndex("AircraftId"); + + b.HasIndex("FlightId"); + + b.HasIndex("LocationId"); + + b.ToTable("SIGHTING", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Password") + .IsRequired() + .HasColumnType("VARCHAR(1000)") + .HasColumnName("Password"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("VARCHAR(50)") + .HasColumnName("UserName"); + + b.HasKey("Id"); + + b.ToTable("USER", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.UserAttribute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(100)") + .HasColumnName("name"); + + b.HasKey("Id"); + + b.ToTable("USER_ATTRIBUTE", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.UserAttributeValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasColumnName("id"); + + b.Property("UserAttributeId") + .HasColumnType("INTEGER") + .HasColumnName("user_attribute_id"); + + b.Property("UserId") + .HasColumnType("INTEGER") + .HasColumnName("user_id"); + + b.Property("Value") + .HasColumnType("VARCHAR(1000)") + .HasColumnName("value"); + + b.HasKey("Id"); + + b.HasIndex("UserAttributeId"); + + b.HasIndex("UserId"); + + b.ToTable("USER_ATTRIBUTE_VALUE", (string)null); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Reporting.AirlineStatistics", b => + { + b.Property("Aircraft") + .HasColumnType("INTEGER"); + + b.Property("Flights") + .HasColumnType("INTEGER"); + + b.Property("Locations") + .HasColumnType("INTEGER"); + + b.Property("Manufacturers") + .HasColumnType("INTEGER"); + + b.Property("Models") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Sightings") + .HasColumnType("INTEGER"); + + b.ToTable("AirlineStatistics"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Reporting.FlightsByMonth", b => + { + b.Property("Flights") + .HasColumnType("INTEGER"); + + b.Property("Month") + .HasColumnType("INTEGER"); + + b.Property("Sightings") + .HasColumnType("INTEGER"); + + b.Property("Year") + .HasColumnType("INTEGER"); + + b.ToTable("FlightsByMonth"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Reporting.LocationStatistics", b => + { + b.Property("Aircraft") + .HasColumnType("INTEGER"); + + b.Property("Flights") + .HasColumnType("INTEGER"); + + b.Property("Manufacturers") + .HasColumnType("INTEGER"); + + b.Property("Models") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Sightings") + .HasColumnType("INTEGER"); + + b.ToTable("LocationStatistics"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Reporting.ManufacturerStatistics", b => + { + b.Property("Aircraft") + .HasColumnType("INTEGER"); + + b.Property("Flights") + .HasColumnType("INTEGER"); + + b.Property("Locations") + .HasColumnType("INTEGER"); + + b.Property("Models") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Sightings") + .HasColumnType("INTEGER"); + + b.ToTable("ManufacturerStatistics"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Reporting.ModelStatistics", b => + { + b.Property("Aircraft") + .HasColumnType("INTEGER"); + + b.Property("Flights") + .HasColumnType("INTEGER"); + + b.Property("Locations") + .HasColumnType("INTEGER"); + + b.Property("Manufacturer") + .HasColumnType("TEXT"); + + b.Property("Model") + .HasColumnType("TEXT"); + + b.Property("Sightings") + .HasColumnType("INTEGER"); + + b.ToTable("ModelStatistics"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Reporting.MyFlights", b => + { + b.Property("Airline") + .HasColumnType("TEXT"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Destination") + .HasColumnType("TEXT"); + + b.Property("Embarkation") + .HasColumnType("TEXT"); + + b.Property("Manufacturer") + .HasColumnType("TEXT"); + + b.Property("Model") + .HasColumnType("TEXT"); + + b.Property("Number") + .HasColumnType("TEXT"); + + b.Property("Registration") + .HasColumnType("TEXT"); + + b.ToTable("MyFlights"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Aircraft", b => + { + b.HasOne("FlightRecorder.Entities.Db.Model", "Model") + .WithMany() + .HasForeignKey("ModelId"); + + b.Navigation("Model"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Airport", b => + { + b.HasOne("FlightRecorder.Entities.Db.Country", "Country") + .WithMany() + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Country"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Flight", b => + { + b.HasOne("FlightRecorder.Entities.Db.Airline", "Airline") + .WithMany() + .HasForeignKey("AirlineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Airline"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Model", b => + { + b.HasOne("FlightRecorder.Entities.Db.Manufacturer", "Manufacturer") + .WithMany() + .HasForeignKey("ManufacturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacturer"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.Sighting", b => + { + b.HasOne("FlightRecorder.Entities.Db.Aircraft", "Aircraft") + .WithMany() + .HasForeignKey("AircraftId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FlightRecorder.Entities.Db.Flight", "Flight") + .WithMany() + .HasForeignKey("FlightId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FlightRecorder.Entities.Db.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Aircraft"); + + b.Navigation("Flight"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.UserAttributeValue", b => + { + b.HasOne("FlightRecorder.Entities.Db.UserAttribute", "UserAttribute") + .WithMany() + .HasForeignKey("UserAttributeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FlightRecorder.Entities.Db.User", null) + .WithMany("Attributes") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAttribute"); + }); + + modelBuilder.Entity("FlightRecorder.Entities.Db.User", b => + { + b.Navigation("Attributes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/FlightRecorder.Data/Migrations/20241201111608_MyFlightReport.cs b/src/FlightRecorder.Data/Migrations/20241201111608_MyFlightReport.cs new file mode 100644 index 0000000..6c7b808 --- /dev/null +++ b/src/FlightRecorder.Data/Migrations/20241201111608_MyFlightReport.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FlightRecorder.Data.Migrations +{ + [ExcludeFromCodeCoverage] + /// + public partial class MyFlightReport : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "MyFlights", + columns: table => new + { + Date = table.Column(type: "TEXT", nullable: false), + Airline = table.Column(type: "TEXT", nullable: true), + Number = table.Column(type: "TEXT", nullable: true), + Embarkation = table.Column(type: "TEXT", nullable: true), + Destination = table.Column(type: "TEXT", nullable: true), + Registration = table.Column(type: "TEXT", nullable: true), + Model = table.Column(type: "TEXT", nullable: true), + Manufacturer = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "MyFlights"); + } + } +} diff --git a/src/FlightRecorder.Data/Migrations/FlightRecorderDbContextModelSnapshot.cs b/src/FlightRecorder.Data/Migrations/FlightRecorderDbContextModelSnapshot.cs index 29f24f0..f5c8b43 100644 --- a/src/FlightRecorder.Data/Migrations/FlightRecorderDbContextModelSnapshot.cs +++ b/src/FlightRecorder.Data/Migrations/FlightRecorderDbContextModelSnapshot.cs @@ -1,5 +1,6 @@ // using System; +using System.Diagnostics.CodeAnalysis; using FlightRecorder.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -9,6 +10,7 @@ namespace FlightRecorder.Data.Migrations { + [ExcludeFromCodeCoverage] [DbContext(typeof(FlightRecorderDbContext))] partial class FlightRecorderDbContextModelSnapshot : ModelSnapshot { @@ -454,6 +456,35 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("ModelStatistics"); }); + modelBuilder.Entity("FlightRecorder.Entities.Reporting.MyFlights", b => + { + b.Property("Airline") + .HasColumnType("TEXT"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Destination") + .HasColumnType("TEXT"); + + b.Property("Embarkation") + .HasColumnType("TEXT"); + + b.Property("Manufacturer") + .HasColumnType("TEXT"); + + b.Property("Model") + .HasColumnType("TEXT"); + + b.Property("Number") + .HasColumnType("TEXT"); + + b.Property("Registration") + .HasColumnType("TEXT"); + + b.ToTable("MyFlights"); + }); + modelBuilder.Entity("FlightRecorder.Entities.Db.Aircraft", b => { b.HasOne("FlightRecorder.Entities.Db.Model", "Model")