diff --git a/src/PackageRegistryService/Migrations/20240625140809_NoNullableFields.Designer.cs b/src/PackageRegistryService/Migrations/20240625140809_NoNullableFields.Designer.cs new file mode 100644 index 0000000..be32fad --- /dev/null +++ b/src/PackageRegistryService/Migrations/20240625140809_NoNullableFields.Designer.cs @@ -0,0 +1,231 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using PackageRegistryService.Models; + +#nullable disable + +namespace PackageRegistryService.Migrations +{ + [DbContext(typeof(ValidationPackageDb))] + [Migration("20240625140809_NoNullableFields")] + partial class NoNullableFields + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("PackageRegistryService.Models.PackageContentHash", b => + { + b.Property("PackageName") + .HasColumnType("text"); + + b.Property("PackageMajorVersion") + .HasColumnType("integer"); + + b.Property("PackageMinorVersion") + .HasColumnType("integer"); + + b.Property("PackagePatchVersion") + .HasColumnType("integer"); + + b.Property("PackagePreReleaseVersionSuffix") + .HasColumnType("text"); + + b.Property("PackageBuildMetadataVersionSuffix") + .HasColumnType("text"); + + b.Property("Hash") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("PackageName", "PackageMajorVersion", "PackageMinorVersion", "PackagePatchVersion", "PackagePreReleaseVersionSuffix", "PackageBuildMetadataVersionSuffix"); + + b.ToTable("Hashes"); + }); + + modelBuilder.Entity("PackageRegistryService.Models.PackageDownloads", b => + { + b.Property("PackageName") + .HasColumnType("text"); + + b.Property("PackageMajorVersion") + .HasColumnType("integer"); + + b.Property("PackageMinorVersion") + .HasColumnType("integer"); + + b.Property("PackagePatchVersion") + .HasColumnType("integer"); + + b.Property("PackagePreReleaseVersionSuffix") + .HasColumnType("text"); + + b.Property("PackageBuildMetadataVersionSuffix") + .HasColumnType("text"); + + b.Property("Downloads") + .HasColumnType("integer"); + + b.HasKey("PackageName", "PackageMajorVersion", "PackageMinorVersion", "PackagePatchVersion", "PackagePreReleaseVersionSuffix", "PackageBuildMetadataVersionSuffix"); + + b.ToTable("Downloads"); + }); + + modelBuilder.Entity("PackageRegistryService.Models.ValidationPackage", b => + { + b.Property("Name") + .HasColumnType("text"); + + b.Property("MajorVersion") + .HasColumnType("integer"); + + b.Property("MinorVersion") + .HasColumnType("integer"); + + b.Property("PatchVersion") + .HasColumnType("integer"); + + b.Property("PreReleaseVersionSuffix") + .HasColumnType("text"); + + b.Property("BuildMetadataVersionSuffix") + .HasColumnType("text"); + + b.Property("CQCHookEndpoint") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("PackageContent") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ReleaseDate") + .HasColumnType("date"); + + b.Property("ReleaseNotes") + .IsRequired() + .HasColumnType("text"); + + b.Property("Summary") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Name", "MajorVersion", "MinorVersion", "PatchVersion", "PreReleaseVersionSuffix", "BuildMetadataVersionSuffix"); + + b.ToTable("ValidationPackages"); + }); + + modelBuilder.Entity("PackageRegistryService.Models.ValidationPackage", b => + { + b.OwnsMany("AVPRIndex.Domain+Author", "Authors", b1 => + { + b1.Property("ValidationPackageName") + .HasColumnType("text"); + + b1.Property("ValidationPackageMajorVersion") + .HasColumnType("integer"); + + b1.Property("ValidationPackageMinorVersion") + .HasColumnType("integer"); + + b1.Property("ValidationPackagePatchVersion") + .HasColumnType("integer"); + + b1.Property("ValidationPackagePreReleaseVersionSuffix") + .HasColumnType("text"); + + b1.Property("ValidationPackageBuildMetadataVersionSuffix") + .HasColumnType("text"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b1.Property("Affiliation") + .HasColumnType("text"); + + b1.Property("AffiliationLink") + .HasColumnType("text"); + + b1.Property("Email") + .HasColumnType("text"); + + b1.Property("FullName") + .HasColumnType("text"); + + b1.HasKey("ValidationPackageName", "ValidationPackageMajorVersion", "ValidationPackageMinorVersion", "ValidationPackagePatchVersion", "ValidationPackagePreReleaseVersionSuffix", "ValidationPackageBuildMetadataVersionSuffix", "Id"); + + b1.ToTable("ValidationPackages"); + + b1.ToJson("Authors"); + + b1.WithOwner() + .HasForeignKey("ValidationPackageName", "ValidationPackageMajorVersion", "ValidationPackageMinorVersion", "ValidationPackagePatchVersion", "ValidationPackagePreReleaseVersionSuffix", "ValidationPackageBuildMetadataVersionSuffix"); + }); + + b.OwnsMany("AVPRIndex.Domain+OntologyAnnotation", "Tags", b1 => + { + b1.Property("ValidationPackageName") + .HasColumnType("text"); + + b1.Property("ValidationPackageMajorVersion") + .HasColumnType("integer"); + + b1.Property("ValidationPackageMinorVersion") + .HasColumnType("integer"); + + b1.Property("ValidationPackagePatchVersion") + .HasColumnType("integer"); + + b1.Property("ValidationPackagePreReleaseVersionSuffix") + .HasColumnType("text"); + + b1.Property("ValidationPackageBuildMetadataVersionSuffix") + .HasColumnType("text"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b1.Property("Name") + .HasColumnType("text"); + + b1.Property("TermAccessionNumber") + .HasColumnType("text"); + + b1.Property("TermSourceREF") + .HasColumnType("text"); + + b1.HasKey("ValidationPackageName", "ValidationPackageMajorVersion", "ValidationPackageMinorVersion", "ValidationPackagePatchVersion", "ValidationPackagePreReleaseVersionSuffix", "ValidationPackageBuildMetadataVersionSuffix", "Id"); + + b1.ToTable("ValidationPackages"); + + b1.ToJson("Tags"); + + b1.WithOwner() + .HasForeignKey("ValidationPackageName", "ValidationPackageMajorVersion", "ValidationPackageMinorVersion", "ValidationPackagePatchVersion", "ValidationPackagePreReleaseVersionSuffix", "ValidationPackageBuildMetadataVersionSuffix"); + }); + + b.Navigation("Authors"); + + b.Navigation("Tags"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/PackageRegistryService/Migrations/20240625140809_NoNullableFields.cs b/src/PackageRegistryService/Migrations/20240625140809_NoNullableFields.cs new file mode 100644 index 0000000..5505d40 --- /dev/null +++ b/src/PackageRegistryService/Migrations/20240625140809_NoNullableFields.cs @@ -0,0 +1,54 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PackageRegistryService.Migrations +{ + /// + public partial class NoNullableFields : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ReleaseNotes", + table: "ValidationPackages", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CQCHookEndpoint", + table: "ValidationPackages", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ReleaseNotes", + table: "ValidationPackages", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CQCHookEndpoint", + table: "ValidationPackages", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + } + } +} diff --git a/src/PackageRegistryService/Migrations/ValidationPackageDbModelSnapshot.cs b/src/PackageRegistryService/Migrations/ValidationPackageDbModelSnapshot.cs index d196a9f..3a4c989 100644 --- a/src/PackageRegistryService/Migrations/ValidationPackageDbModelSnapshot.cs +++ b/src/PackageRegistryService/Migrations/ValidationPackageDbModelSnapshot.cs @@ -100,6 +100,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("text"); b.Property("CQCHookEndpoint") + .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -114,6 +115,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("date"); b.Property("ReleaseNotes") + .IsRequired() .HasColumnType("text"); b.Property("Summary") diff --git a/src/PackageRegistryService/Models/ValidationPackage.cs b/src/PackageRegistryService/Models/ValidationPackage.cs index 1a48c5c..eef43a9 100644 --- a/src/PackageRegistryService/Models/ValidationPackage.cs +++ b/src/PackageRegistryService/Models/ValidationPackage.cs @@ -81,22 +81,22 @@ public class ValidationPackage /// /// /// - public ICollection? Tags { get; set; } + public ICollection Tags { get; set; } = Array.Empty(); /// /// /// - public string? ReleaseNotes { get; set; } + public string ReleaseNotes { get; set; } = ""; /// /// /// - public string? CQCHookEndpoint { get; set; } + public string CQCHookEndpoint { get; set; } = ""; /// /// /// - public ICollection? Authors { get; set; } // https://www.learnentityframeworkcore.com/relationships#navigation-properties + public ICollection Authors { get; set; } = Array.Empty();// https://www.learnentityframeworkcore.com/relationships#navigation-properties /// ///