Got the new ui flow working and the models updated. Need to get changes written to the database.

This commit is contained in:
Vincent Allen
2025-08-11 10:02:45 -04:00
parent 6475a28263
commit 3d82040e75
456 changed files with 17237 additions and 3851 deletions

View File

@@ -0,0 +1,88 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System.Text.Json;
namespace OpenArchival.DataAccess;
public class ArchiveDbContext : DbContext
{
public DbSet<ArtifactGrouping> ArtifactGroupings { get; set; }
public DbSet<ArtifactEntry> ArtifactEntries { get; set; }
public DbSet<ArtifactEntryTag> ArtifactEntryTags { get; set; }
public DbSet<ArchiveCategory> ArchiveCategories { get; set; }
public DbSet<ListedName> ArtifactAssociatedNames { get; set; }
public DbSet<FilePathListing> ArtifactFilePaths { get; set; }
public DbSet<ArchiveCategory> ArtifactGroupingCategories { get; set; }
public DbSet<ArtifactDefect> ArtifactDefects { get; set; }
public DbSet<ArtifactStorageLocation> ArtifactStorageLocations { get; set; }
public DbSet<ArtifactType> ArtifactTypes { get; set; }
public ArchiveDbContext(DbContextOptions<ArchiveDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ArtifactGrouping>()
.HasMany(p => p.RelatedArtifactGroupings)
.WithMany()
.UsingEntity(j => j.ToTable("RelatedGroupings"));
modelBuilder.Entity<ArtifactEntry>()
.HasMany(p => p.Files)
.WithOne(p => p.ParentArtifactEntry)
.HasForeignKey(p => p.ParentArtifactEntryId)
.IsRequired(false);
modelBuilder.Entity<ArtifactGrouping>()
.OwnsOne(p => p.IdentifierFields)
.ToJson();
modelBuilder.Entity<ArtifactEntry>(builder =>
{
builder.Property(p => p.FileTextContent)
.HasConversion
(
v => JsonSerializer.Serialize
(v, new JsonSerializerOptions()),
v => JsonSerializer.Deserialize<Dictionary<string, string>>
(v, new JsonSerializerOptions()) ?? new Dictionary<string, string>()
);
});
var dictionaryComparer = new ValueComparer<Dictionary<string, string>>(
(dictionary1, dictionary2) => dictionary1.OrderBy(pair => pair.Key)
.SequenceEqual(dictionary2.OrderBy(pair => pair.Key)),
dictionary => dictionary.Aggregate(
0,
(aggregatedHash, pair) => HashCode.Combine(aggregatedHash, pair.Key.GetHashCode(), pair.Value.GetHashCode())),
sourceDictionary => new Dictionary<string, string>(sourceDictionary)
);
modelBuilder.Entity<ArtifactEntry>(builder =>
{
builder.Property(p => p.FileTextContent)
.HasConversion
(
v => JsonSerializer.Serialize(v, new JsonSerializerOptions()),
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, new JsonSerializerOptions()) ?? new Dictionary<string, string>()
).Metadata
.SetValueComparer(dictionaryComparer);
});
}
}

View File

@@ -0,0 +1,380 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OpenArchival.DataAccess;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
[DbContext(typeof(ArchiveDbContext))]
[Migration("20250806141452_AllModels")]
partial class AllModels
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.Property<int>("ArtifactEntriesId")
.HasColumnType("integer");
b.Property<int>("TagsId")
.HasColumnType("integer");
b.HasKey("ArtifactEntriesId", "TagsId");
b.HasIndex("TagsId");
b.ToTable("ArtifactEntryArtifactEntryTag");
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("RelatedArtifactGroupingsId")
.HasColumnType("integer");
b.HasKey("ArtifactGroupingId", "RelatedArtifactGroupingsId");
b.HasIndex("RelatedArtifactGroupingsId");
b.ToTable("RelatedGroupings", (string)null);
});
modelBuilder.Entity("OpenArchival.DataAccess.ArchiveCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("FieldDescriptions")
.IsRequired()
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("FieldNames")
.IsRequired()
.HasColumnType("text[]");
b.Property<string>("FieldSeparator")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArchiveCategory");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactDefects");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ArtifactNumber")
.HasColumnType("text");
b.PrimitiveCollection<List<DateTime>>("AssociatedDates")
.HasColumnType("timestamp with time zone[]");
b.PrimitiveCollection<List<string>>("Defects")
.HasColumnType("text[]");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("FileTextContent")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.PrimitiveCollection<List<string>>("Links")
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("ListedNames")
.HasColumnType("text[]");
b.Property<int?>("ParentArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("StorageLocation")
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactGroupingId");
b.ToTable("ArtifactEntries");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ArtifactGroupingId");
b.ToTable("ArtifactEntryTags");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CategoryId")
.HasColumnType("integer");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("ArtifactGroupings");
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Title")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactAssocaitedNames");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("OriginalName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactFilePaths");
});
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", null)
.WithMany()
.HasForeignKey("ArtifactEntriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactEntryTag", null)
.WithMany()
.HasForeignKey("TagsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("ArtifactGroupingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("RelatedArtifactGroupingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", "ParentArtifactGrouping")
.WithMany("ChildArtifactEntries")
.HasForeignKey("ParentArtifactGroupingId");
b.Navigation("ParentArtifactGrouping");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany("ChildTags")
.HasForeignKey("ArtifactGroupingId");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArchiveCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("OpenArchival.DataAccess.IdentifierFields", "IdentifierFields", b1 =>
{
b1.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b1.PrimitiveCollection<List<string>>("Values")
.IsRequired()
.HasColumnType("text[]");
b1.HasKey("ArtifactGroupingId");
b1.ToTable("ArtifactGroupings");
b1.ToJson("IdentifierFields");
b1.WithOwner()
.HasForeignKey("ArtifactGroupingId");
});
b.Navigation("Category");
b.Navigation("IdentifierFields")
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany()
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany("Files")
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Navigation("Files");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Navigation("ChildArtifactEntries");
b.Navigation("ChildTags");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,275 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
/// <inheritdoc />
public partial class AllModels : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ArchiveCategory",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
FieldSeparator = table.Column<string>(type: "text", nullable: false),
FieldNames = table.Column<List<string>>(type: "text[]", nullable: false),
FieldDescriptions = table.Column<List<string>>(type: "text[]", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArchiveCategory", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ArtifactDefects",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Description = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactDefects", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ArtifactGroupings",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CategoryId = table.Column<int>(type: "integer", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
Type = table.Column<string>(type: "text", nullable: true),
IsPublicallyVisible = table.Column<bool>(type: "boolean", nullable: false),
IdentifierFields = table.Column<string>(type: "jsonb", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactGroupings", x => x.Id);
table.ForeignKey(
name: "FK_ArtifactGroupings_ArchiveCategory_CategoryId",
column: x => x.CategoryId,
principalTable: "ArchiveCategory",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ArtifactEntries",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ArtifactNumber = table.Column<string>(type: "text", nullable: true),
Title = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
StorageLocation = table.Column<string>(type: "text", nullable: true),
ListedNames = table.Column<List<string>>(type: "text[]", nullable: true),
AssociatedDates = table.Column<List<DateTime>>(type: "timestamp with time zone[]", nullable: true),
Defects = table.Column<List<string>>(type: "text[]", nullable: true),
Links = table.Column<List<string>>(type: "text[]", nullable: true),
ParentArtifactGroupingId = table.Column<int>(type: "integer", nullable: true),
FileTextContent = table.Column<string>(type: "text", nullable: true),
IsPublicallyVisible = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactEntries", x => x.Id);
table.ForeignKey(
name: "FK_ArtifactEntries_ArtifactGroupings_ParentArtifactGroupingId",
column: x => x.ParentArtifactGroupingId,
principalTable: "ArtifactGroupings",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "ArtifactEntryTags",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
ArtifactGroupingId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactEntryTags", x => x.Id);
table.ForeignKey(
name: "FK_ArtifactEntryTags_ArtifactGroupings_ArtifactGroupingId",
column: x => x.ArtifactGroupingId,
principalTable: "ArtifactGroupings",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "RelatedGroupings",
columns: table => new
{
ArtifactGroupingId = table.Column<int>(type: "integer", nullable: false),
RelatedArtifactGroupingsId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RelatedGroupings", x => new { x.ArtifactGroupingId, x.RelatedArtifactGroupingsId });
table.ForeignKey(
name: "FK_RelatedGroupings_ArtifactGroupings_ArtifactGroupingId",
column: x => x.ArtifactGroupingId,
principalTable: "ArtifactGroupings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RelatedGroupings_ArtifactGroupings_RelatedArtifactGroupings~",
column: x => x.RelatedArtifactGroupingsId,
principalTable: "ArtifactGroupings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ArtifactAssocaitedNames",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ParentArtifactEntryId = table.Column<int>(type: "integer", nullable: false),
Title = table.Column<string>(type: "text", nullable: true),
FirstName = table.Column<string>(type: "text", nullable: false),
LastName = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactAssocaitedNames", x => x.Id);
table.ForeignKey(
name: "FK_ArtifactAssocaitedNames_ArtifactEntries_ParentArtifactEntry~",
column: x => x.ParentArtifactEntryId,
principalTable: "ArtifactEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ArtifactFilePaths",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ParentArtifactEntryId = table.Column<int>(type: "integer", nullable: false),
OriginalName = table.Column<string>(type: "text", nullable: false),
Path = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactFilePaths", x => x.Id);
table.ForeignKey(
name: "FK_ArtifactFilePaths_ArtifactEntries_ParentArtifactEntryId",
column: x => x.ParentArtifactEntryId,
principalTable: "ArtifactEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ArtifactEntryArtifactEntryTag",
columns: table => new
{
ArtifactEntriesId = table.Column<int>(type: "integer", nullable: false),
TagsId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactEntryArtifactEntryTag", x => new { x.ArtifactEntriesId, x.TagsId });
table.ForeignKey(
name: "FK_ArtifactEntryArtifactEntryTag_ArtifactEntries_ArtifactEntri~",
column: x => x.ArtifactEntriesId,
principalTable: "ArtifactEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ArtifactEntryArtifactEntryTag_ArtifactEntryTags_TagsId",
column: x => x.TagsId,
principalTable: "ArtifactEntryTags",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ArtifactAssocaitedNames_ParentArtifactEntryId",
table: "ArtifactAssocaitedNames",
column: "ParentArtifactEntryId");
migrationBuilder.CreateIndex(
name: "IX_ArtifactEntries_ParentArtifactGroupingId",
table: "ArtifactEntries",
column: "ParentArtifactGroupingId");
migrationBuilder.CreateIndex(
name: "IX_ArtifactEntryArtifactEntryTag_TagsId",
table: "ArtifactEntryArtifactEntryTag",
column: "TagsId");
migrationBuilder.CreateIndex(
name: "IX_ArtifactEntryTags_ArtifactGroupingId",
table: "ArtifactEntryTags",
column: "ArtifactGroupingId");
migrationBuilder.CreateIndex(
name: "IX_ArtifactFilePaths_ParentArtifactEntryId",
table: "ArtifactFilePaths",
column: "ParentArtifactEntryId");
migrationBuilder.CreateIndex(
name: "IX_ArtifactGroupings_CategoryId",
table: "ArtifactGroupings",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_RelatedGroupings_RelatedArtifactGroupingsId",
table: "RelatedGroupings",
column: "RelatedArtifactGroupingsId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ArtifactAssocaitedNames");
migrationBuilder.DropTable(
name: "ArtifactDefects");
migrationBuilder.DropTable(
name: "ArtifactEntryArtifactEntryTag");
migrationBuilder.DropTable(
name: "ArtifactFilePaths");
migrationBuilder.DropTable(
name: "RelatedGroupings");
migrationBuilder.DropTable(
name: "ArtifactEntryTags");
migrationBuilder.DropTable(
name: "ArtifactEntries");
migrationBuilder.DropTable(
name: "ArtifactGroupings");
migrationBuilder.DropTable(
name: "ArchiveCategory");
}
}
}

View File

@@ -0,0 +1,380 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OpenArchival.DataAccess;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
[DbContext(typeof(ArchiveDbContext))]
[Migration("20250806144037_AllModelsFixedComparer")]
partial class AllModelsFixedComparer
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.Property<int>("ArtifactEntriesId")
.HasColumnType("integer");
b.Property<int>("TagsId")
.HasColumnType("integer");
b.HasKey("ArtifactEntriesId", "TagsId");
b.HasIndex("TagsId");
b.ToTable("ArtifactEntryArtifactEntryTag");
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("RelatedArtifactGroupingsId")
.HasColumnType("integer");
b.HasKey("ArtifactGroupingId", "RelatedArtifactGroupingsId");
b.HasIndex("RelatedArtifactGroupingsId");
b.ToTable("RelatedGroupings", (string)null);
});
modelBuilder.Entity("OpenArchival.DataAccess.ArchiveCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("FieldDescriptions")
.IsRequired()
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("FieldNames")
.IsRequired()
.HasColumnType("text[]");
b.Property<string>("FieldSeparator")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArchiveCategory");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactDefects");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ArtifactNumber")
.HasColumnType("text");
b.PrimitiveCollection<List<DateTime>>("AssociatedDates")
.HasColumnType("timestamp with time zone[]");
b.PrimitiveCollection<List<string>>("Defects")
.HasColumnType("text[]");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("FileTextContent")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.PrimitiveCollection<List<string>>("Links")
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("ListedNames")
.HasColumnType("text[]");
b.Property<int?>("ParentArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("StorageLocation")
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactGroupingId");
b.ToTable("ArtifactEntries");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ArtifactGroupingId");
b.ToTable("ArtifactEntryTags");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CategoryId")
.HasColumnType("integer");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("ArtifactGroupings");
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Title")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactAssocaitedNames");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("OriginalName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactFilePaths");
});
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", null)
.WithMany()
.HasForeignKey("ArtifactEntriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactEntryTag", null)
.WithMany()
.HasForeignKey("TagsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("ArtifactGroupingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("RelatedArtifactGroupingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", "ParentArtifactGrouping")
.WithMany("ChildArtifactEntries")
.HasForeignKey("ParentArtifactGroupingId");
b.Navigation("ParentArtifactGrouping");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany("ChildTags")
.HasForeignKey("ArtifactGroupingId");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArchiveCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("OpenArchival.DataAccess.IdentifierFields", "IdentifierFields", b1 =>
{
b1.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b1.PrimitiveCollection<List<string>>("Values")
.IsRequired()
.HasColumnType("text[]");
b1.HasKey("ArtifactGroupingId");
b1.ToTable("ArtifactGroupings");
b1.ToJson("IdentifierFields");
b1.WithOwner()
.HasForeignKey("ArtifactGroupingId");
});
b.Navigation("Category");
b.Navigation("IdentifierFields")
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany()
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany("Files")
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Navigation("Files");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Navigation("ChildArtifactEntries");
b.Navigation("ChildTags");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
/// <inheritdoc />
public partial class AllModelsFixedComparer : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -0,0 +1,378 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OpenArchival.DataAccess;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
[DbContext(typeof(ArchiveDbContext))]
[Migration("20250806174205_NullableParentArtifactEntryId")]
partial class NullableParentArtifactEntryId
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.Property<int>("ArtifactEntriesId")
.HasColumnType("integer");
b.Property<int>("TagsId")
.HasColumnType("integer");
b.HasKey("ArtifactEntriesId", "TagsId");
b.HasIndex("TagsId");
b.ToTable("ArtifactEntryArtifactEntryTag");
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("RelatedArtifactGroupingsId")
.HasColumnType("integer");
b.HasKey("ArtifactGroupingId", "RelatedArtifactGroupingsId");
b.HasIndex("RelatedArtifactGroupingsId");
b.ToTable("RelatedGroupings", (string)null);
});
modelBuilder.Entity("OpenArchival.DataAccess.ArchiveCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("FieldDescriptions")
.IsRequired()
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("FieldNames")
.IsRequired()
.HasColumnType("text[]");
b.Property<string>("FieldSeparator")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArchiveCategory");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactDefects");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ArtifactNumber")
.HasColumnType("text");
b.PrimitiveCollection<List<DateTime>>("AssociatedDates")
.HasColumnType("timestamp with time zone[]");
b.PrimitiveCollection<List<string>>("Defects")
.HasColumnType("text[]");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("FileTextContent")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.PrimitiveCollection<List<string>>("Links")
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("ListedNames")
.HasColumnType("text[]");
b.Property<int?>("ParentArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("StorageLocation")
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactGroupingId");
b.ToTable("ArtifactEntries");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ArtifactGroupingId");
b.ToTable("ArtifactEntryTags");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CategoryId")
.HasColumnType("integer");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("ArtifactGroupings");
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Title")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactAssocaitedNames");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("OriginalName")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactFilePaths");
});
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", null)
.WithMany()
.HasForeignKey("ArtifactEntriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactEntryTag", null)
.WithMany()
.HasForeignKey("TagsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("ArtifactGroupingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("RelatedArtifactGroupingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", "ParentArtifactGrouping")
.WithMany("ChildArtifactEntries")
.HasForeignKey("ParentArtifactGroupingId");
b.Navigation("ParentArtifactGrouping");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany("ChildTags")
.HasForeignKey("ArtifactGroupingId");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArchiveCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("OpenArchival.DataAccess.IdentifierFields", "IdentifierFields", b1 =>
{
b1.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b1.PrimitiveCollection<List<string>>("Values")
.IsRequired()
.HasColumnType("text[]");
b1.HasKey("ArtifactGroupingId");
b1.ToTable("ArtifactGroupings");
b1.ToJson("IdentifierFields");
b1.WithOwner()
.HasForeignKey("ArtifactGroupingId");
});
b.Navigation("Category");
b.Navigation("IdentifierFields")
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany()
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany("Files")
.HasForeignKey("ParentArtifactEntryId");
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Navigation("Files");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Navigation("ChildArtifactEntries");
b.Navigation("ChildTags");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
/// <inheritdoc />
public partial class NullableParentArtifactEntryId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ArtifactFilePaths_ArtifactEntries_ParentArtifactEntryId",
table: "ArtifactFilePaths");
migrationBuilder.AlterColumn<int>(
name: "ParentArtifactEntryId",
table: "ArtifactFilePaths",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AddForeignKey(
name: "FK_ArtifactFilePaths_ArtifactEntries_ParentArtifactEntryId",
table: "ArtifactFilePaths",
column: "ParentArtifactEntryId",
principalTable: "ArtifactEntries",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ArtifactFilePaths_ArtifactEntries_ParentArtifactEntryId",
table: "ArtifactFilePaths");
migrationBuilder.AlterColumn<int>(
name: "ParentArtifactEntryId",
table: "ArtifactFilePaths",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_ArtifactFilePaths_ArtifactEntries_ParentArtifactEntryId",
table: "ArtifactFilePaths",
column: "ParentArtifactEntryId",
principalTable: "ArtifactEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -0,0 +1,405 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OpenArchival.DataAccess;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
[DbContext(typeof(ArchiveDbContext))]
[Migration("20250807131954_AddStorageLocations")]
partial class AddStorageLocations
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.Property<int>("ArtifactEntriesId")
.HasColumnType("integer");
b.Property<int>("TagsId")
.HasColumnType("integer");
b.HasKey("ArtifactEntriesId", "TagsId");
b.HasIndex("TagsId");
b.ToTable("ArtifactEntryArtifactEntryTag");
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("RelatedArtifactGroupingsId")
.HasColumnType("integer");
b.HasKey("ArtifactGroupingId", "RelatedArtifactGroupingsId");
b.HasIndex("RelatedArtifactGroupingsId");
b.ToTable("RelatedGroupings", (string)null);
});
modelBuilder.Entity("OpenArchival.DataAccess.ArchiveCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("FieldDescriptions")
.IsRequired()
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("FieldNames")
.IsRequired()
.HasColumnType("text[]");
b.Property<string>("FieldSeparator")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArchiveCategory");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactDefects");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ArtifactNumber")
.HasColumnType("text");
b.PrimitiveCollection<List<DateTime>>("AssociatedDates")
.HasColumnType("timestamp with time zone[]");
b.PrimitiveCollection<List<string>>("Defects")
.HasColumnType("text[]");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("FileTextContent")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.PrimitiveCollection<List<string>>("Links")
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("ListedNames")
.HasColumnType("text[]");
b.Property<int?>("ParentArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("StorageLocationId")
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactGroupingId");
b.HasIndex("StorageLocationId");
b.ToTable("ArtifactEntries");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ArtifactGroupingId");
b.ToTable("ArtifactEntryTags");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CategoryId")
.HasColumnType("integer");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("ArtifactGroupings");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactStorageLocation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Location")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactStorageLocations");
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Title")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactAssocaitedNames");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("OriginalName")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactFilePaths");
});
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", null)
.WithMany()
.HasForeignKey("ArtifactEntriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactEntryTag", null)
.WithMany()
.HasForeignKey("TagsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("ArtifactGroupingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("RelatedArtifactGroupingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", "ParentArtifactGrouping")
.WithMany("ChildArtifactEntries")
.HasForeignKey("ParentArtifactGroupingId");
b.HasOne("OpenArchival.DataAccess.ArtifactStorageLocation", "StorageLocation")
.WithMany()
.HasForeignKey("StorageLocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactGrouping");
b.Navigation("StorageLocation");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany("ChildTags")
.HasForeignKey("ArtifactGroupingId");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArchiveCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("OpenArchival.DataAccess.IdentifierFields", "IdentifierFields", b1 =>
{
b1.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b1.PrimitiveCollection<List<string>>("Values")
.IsRequired()
.HasColumnType("text[]");
b1.HasKey("ArtifactGroupingId");
b1.ToTable("ArtifactGroupings");
b1.ToJson("IdentifierFields");
b1.WithOwner()
.HasForeignKey("ArtifactGroupingId");
});
b.Navigation("Category");
b.Navigation("IdentifierFields")
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany()
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany("Files")
.HasForeignKey("ParentArtifactEntryId");
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Navigation("Files");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Navigation("ChildArtifactEntries");
b.Navigation("ChildTags");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,77 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
/// <inheritdoc />
public partial class AddStorageLocations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "StorageLocation",
table: "ArtifactEntries");
migrationBuilder.AddColumn<int>(
name: "StorageLocationId",
table: "ArtifactEntries",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "ArtifactStorageLocations",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Location = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactStorageLocations", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_ArtifactEntries_StorageLocationId",
table: "ArtifactEntries",
column: "StorageLocationId");
migrationBuilder.AddForeignKey(
name: "FK_ArtifactEntries_ArtifactStorageLocations_StorageLocationId",
table: "ArtifactEntries",
column: "StorageLocationId",
principalTable: "ArtifactStorageLocations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ArtifactEntries_ArtifactStorageLocations_StorageLocationId",
table: "ArtifactEntries");
migrationBuilder.DropTable(
name: "ArtifactStorageLocations");
migrationBuilder.DropIndex(
name: "IX_ArtifactEntries_StorageLocationId",
table: "ArtifactEntries");
migrationBuilder.DropColumn(
name: "StorageLocationId",
table: "ArtifactEntries");
migrationBuilder.AddColumn<string>(
name: "StorageLocation",
table: "ArtifactEntries",
type: "text",
nullable: true);
}
}
}

View File

@@ -0,0 +1,405 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OpenArchival.DataAccess;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
[DbContext(typeof(ArchiveDbContext))]
[Migration("20250807132100_FixType")]
partial class FixType
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.Property<int>("ArtifactEntriesId")
.HasColumnType("integer");
b.Property<int>("TagsId")
.HasColumnType("integer");
b.HasKey("ArtifactEntriesId", "TagsId");
b.HasIndex("TagsId");
b.ToTable("ArtifactEntryArtifactEntryTag");
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("RelatedArtifactGroupingsId")
.HasColumnType("integer");
b.HasKey("ArtifactGroupingId", "RelatedArtifactGroupingsId");
b.HasIndex("RelatedArtifactGroupingsId");
b.ToTable("RelatedGroupings", (string)null);
});
modelBuilder.Entity("OpenArchival.DataAccess.ArchiveCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("FieldDescriptions")
.IsRequired()
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("FieldNames")
.IsRequired()
.HasColumnType("text[]");
b.Property<string>("FieldSeparator")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArchiveCategory");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactDefects");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ArtifactNumber")
.HasColumnType("text");
b.PrimitiveCollection<List<DateTime>>("AssociatedDates")
.HasColumnType("timestamp with time zone[]");
b.PrimitiveCollection<List<string>>("Defects")
.HasColumnType("text[]");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("FileTextContent")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.PrimitiveCollection<List<string>>("Links")
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("ListedNames")
.HasColumnType("text[]");
b.Property<int?>("ParentArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("StorageLocationId")
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactGroupingId");
b.HasIndex("StorageLocationId");
b.ToTable("ArtifactEntries");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ArtifactGroupingId");
b.ToTable("ArtifactEntryTags");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CategoryId")
.HasColumnType("integer");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("ArtifactGroupings");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactStorageLocation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Location")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactStorageLocations");
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Title")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactAssocaitedNames");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("OriginalName")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactFilePaths");
});
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", null)
.WithMany()
.HasForeignKey("ArtifactEntriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactEntryTag", null)
.WithMany()
.HasForeignKey("TagsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("ArtifactGroupingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("RelatedArtifactGroupingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", "ParentArtifactGrouping")
.WithMany("ChildArtifactEntries")
.HasForeignKey("ParentArtifactGroupingId");
b.HasOne("OpenArchival.DataAccess.ArtifactStorageLocation", "StorageLocation")
.WithMany()
.HasForeignKey("StorageLocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactGrouping");
b.Navigation("StorageLocation");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany("ChildTags")
.HasForeignKey("ArtifactGroupingId");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArchiveCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("OpenArchival.DataAccess.IdentifierFields", "IdentifierFields", b1 =>
{
b1.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b1.PrimitiveCollection<List<string>>("Values")
.IsRequired()
.HasColumnType("text[]");
b1.HasKey("ArtifactGroupingId");
b1.ToTable("ArtifactGroupings");
b1.ToJson("IdentifierFields");
b1.WithOwner()
.HasForeignKey("ArtifactGroupingId");
});
b.Navigation("Category");
b.Navigation("IdentifierFields")
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany()
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany("Files")
.HasForeignKey("ParentArtifactEntryId");
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Navigation("Files");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Navigation("ChildArtifactEntries");
b.Navigation("ChildTags");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
/// <inheritdoc />
public partial class FixType : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -0,0 +1,422 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OpenArchival.DataAccess;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
[DbContext(typeof(ArchiveDbContext))]
[Migration("20250807180849_FixTypo")]
partial class FixTypo
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.Property<int>("ArtifactEntriesId")
.HasColumnType("integer");
b.Property<int>("TagsId")
.HasColumnType("integer");
b.HasKey("ArtifactEntriesId", "TagsId");
b.HasIndex("TagsId");
b.ToTable("ArtifactEntryArtifactEntryTag");
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("RelatedArtifactGroupingsId")
.HasColumnType("integer");
b.HasKey("ArtifactGroupingId", "RelatedArtifactGroupingsId");
b.HasIndex("RelatedArtifactGroupingsId");
b.ToTable("RelatedGroupings", (string)null);
});
modelBuilder.Entity("OpenArchival.DataAccess.ArchiveCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("FieldDescriptions")
.IsRequired()
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("FieldNames")
.IsRequired()
.HasColumnType("text[]");
b.Property<string>("FieldSeparator")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArchiveCategory");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactDefects");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ArtifactNumber")
.HasColumnType("text");
b.PrimitiveCollection<List<DateTime>>("AssociatedDates")
.HasColumnType("timestamp with time zone[]");
b.PrimitiveCollection<List<string>>("Defects")
.HasColumnType("text[]");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("FileTextContent")
.HasColumnType("text");
b.Property<bool>("IsPubliclyVisible")
.HasColumnType("boolean");
b.PrimitiveCollection<List<string>>("Links")
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("ListedNames")
.HasColumnType("text[]");
b.Property<int?>("ParentArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("StorageLocationId")
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactGroupingId");
b.HasIndex("StorageLocationId");
b.ToTable("ArtifactEntries");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ArtifactGroupingId");
b.ToTable("ArtifactEntryTags");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CategoryId")
.HasColumnType("integer");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("ArtifactGroupings");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactStorageLocation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Location")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactStorageLocations");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactTypes");
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Title")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactAssociatedNames");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("OriginalName")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactFilePaths");
});
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", null)
.WithMany()
.HasForeignKey("ArtifactEntriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactEntryTag", null)
.WithMany()
.HasForeignKey("TagsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("ArtifactGroupingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("RelatedArtifactGroupingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", "ParentArtifactGrouping")
.WithMany("ChildArtifactEntries")
.HasForeignKey("ParentArtifactGroupingId");
b.HasOne("OpenArchival.DataAccess.ArtifactStorageLocation", "StorageLocation")
.WithMany()
.HasForeignKey("StorageLocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactGrouping");
b.Navigation("StorageLocation");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany("ChildTags")
.HasForeignKey("ArtifactGroupingId");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArchiveCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("OpenArchival.DataAccess.IdentifierFields", "IdentifierFields", b1 =>
{
b1.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b1.PrimitiveCollection<List<string>>("Values")
.IsRequired()
.HasColumnType("text[]");
b1.HasKey("ArtifactGroupingId");
b1.ToTable("ArtifactGroupings");
b1.ToJson("IdentifierFields");
b1.WithOwner()
.HasForeignKey("ArtifactGroupingId");
});
b.Navigation("Category");
b.Navigation("IdentifierFields")
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany()
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany("Files")
.HasForeignKey("ParentArtifactEntryId");
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Navigation("Files");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Navigation("ChildArtifactEntries");
b.Navigation("ChildTags");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,105 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
/// <inheritdoc />
public partial class FixTypo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ArtifactAssocaitedNames_ArtifactEntries_ParentArtifactEntry~",
table: "ArtifactAssocaitedNames");
migrationBuilder.DropPrimaryKey(
name: "PK_ArtifactAssocaitedNames",
table: "ArtifactAssocaitedNames");
migrationBuilder.RenameTable(
name: "ArtifactAssocaitedNames",
newName: "ArtifactAssociatedNames");
migrationBuilder.RenameColumn(
name: "IsPublicallyVisible",
table: "ArtifactEntries",
newName: "IsPubliclyVisible");
migrationBuilder.RenameIndex(
name: "IX_ArtifactAssocaitedNames_ParentArtifactEntryId",
table: "ArtifactAssociatedNames",
newName: "IX_ArtifactAssociatedNames_ParentArtifactEntryId");
migrationBuilder.AddPrimaryKey(
name: "PK_ArtifactAssociatedNames",
table: "ArtifactAssociatedNames",
column: "Id");
migrationBuilder.CreateTable(
name: "ArtifactTypes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactTypes", x => x.Id);
});
migrationBuilder.AddForeignKey(
name: "FK_ArtifactAssociatedNames_ArtifactEntries_ParentArtifactEntry~",
table: "ArtifactAssociatedNames",
column: "ParentArtifactEntryId",
principalTable: "ArtifactEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ArtifactAssociatedNames_ArtifactEntries_ParentArtifactEntry~",
table: "ArtifactAssociatedNames");
migrationBuilder.DropTable(
name: "ArtifactTypes");
migrationBuilder.DropPrimaryKey(
name: "PK_ArtifactAssociatedNames",
table: "ArtifactAssociatedNames");
migrationBuilder.RenameTable(
name: "ArtifactAssociatedNames",
newName: "ArtifactAssocaitedNames");
migrationBuilder.RenameColumn(
name: "IsPubliclyVisible",
table: "ArtifactEntries",
newName: "IsPublicallyVisible");
migrationBuilder.RenameIndex(
name: "IX_ArtifactAssociatedNames_ParentArtifactEntryId",
table: "ArtifactAssocaitedNames",
newName: "IX_ArtifactAssocaitedNames_ParentArtifactEntryId");
migrationBuilder.AddPrimaryKey(
name: "PK_ArtifactAssocaitedNames",
table: "ArtifactAssocaitedNames",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ArtifactAssocaitedNames_ArtifactEntries_ParentArtifactEntry~",
table: "ArtifactAssocaitedNames",
column: "ParentArtifactEntryId",
principalTable: "ArtifactEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -0,0 +1,419 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using OpenArchival.DataAccess;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
[DbContext(typeof(ArchiveDbContext))]
partial class ArchiveDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.Property<int>("ArtifactEntriesId")
.HasColumnType("integer");
b.Property<int>("TagsId")
.HasColumnType("integer");
b.HasKey("ArtifactEntriesId", "TagsId");
b.HasIndex("TagsId");
b.ToTable("ArtifactEntryArtifactEntryTag");
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("RelatedArtifactGroupingsId")
.HasColumnType("integer");
b.HasKey("ArtifactGroupingId", "RelatedArtifactGroupingsId");
b.HasIndex("RelatedArtifactGroupingsId");
b.ToTable("RelatedGroupings", (string)null);
});
modelBuilder.Entity("OpenArchival.DataAccess.ArchiveCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("FieldDescriptions")
.IsRequired()
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("FieldNames")
.IsRequired()
.HasColumnType("text[]");
b.Property<string>("FieldSeparator")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArchiveCategory");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactDefects");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ArtifactNumber")
.HasColumnType("text");
b.PrimitiveCollection<List<DateTime>>("AssociatedDates")
.HasColumnType("timestamp with time zone[]");
b.PrimitiveCollection<List<string>>("Defects")
.HasColumnType("text[]");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("FileTextContent")
.HasColumnType("text");
b.Property<bool>("IsPubliclyVisible")
.HasColumnType("boolean");
b.PrimitiveCollection<List<string>>("Links")
.HasColumnType("text[]");
b.PrimitiveCollection<List<string>>("ListedNames")
.HasColumnType("text[]");
b.Property<int?>("ParentArtifactGroupingId")
.HasColumnType("integer");
b.Property<int>("StorageLocationId")
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactGroupingId");
b.HasIndex("StorageLocationId");
b.ToTable("ArtifactEntries");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ArtifactGroupingId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ArtifactGroupingId");
b.ToTable("ArtifactEntryTags");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CategoryId")
.HasColumnType("integer");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsPublicallyVisible")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("ArtifactGroupings");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactStorageLocation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Location")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactStorageLocations");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("ArtifactTypes");
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Title")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactAssociatedNames");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("OriginalName")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ParentArtifactEntryId")
.HasColumnType("integer");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentArtifactEntryId");
b.ToTable("ArtifactFilePaths");
});
modelBuilder.Entity("ArtifactEntryArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", null)
.WithMany()
.HasForeignKey("ArtifactEntriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactEntryTag", null)
.WithMany()
.HasForeignKey("TagsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ArtifactGroupingArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("ArtifactGroupingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany()
.HasForeignKey("RelatedArtifactGroupingsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", "ParentArtifactGrouping")
.WithMany("ChildArtifactEntries")
.HasForeignKey("ParentArtifactGroupingId");
b.HasOne("OpenArchival.DataAccess.ArtifactStorageLocation", "StorageLocation")
.WithMany()
.HasForeignKey("StorageLocationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactGrouping");
b.Navigation("StorageLocation");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntryTag", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactGrouping", null)
.WithMany("ChildTags")
.HasForeignKey("ArtifactGroupingId");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.HasOne("OpenArchival.DataAccess.ArchiveCategory", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("OpenArchival.DataAccess.IdentifierFields", "IdentifierFields", b1 =>
{
b1.Property<int>("ArtifactGroupingId")
.HasColumnType("integer");
b1.PrimitiveCollection<List<string>>("Values")
.IsRequired()
.HasColumnType("text[]");
b1.HasKey("ArtifactGroupingId");
b1.ToTable("ArtifactGroupings");
b1.ToJson("IdentifierFields");
b1.WithOwner()
.HasForeignKey("ArtifactGroupingId");
});
b.Navigation("Category");
b.Navigation("IdentifierFields")
.IsRequired();
});
modelBuilder.Entity("OpenArchival.DataAccess.AssociatedName", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany()
.HasForeignKey("ParentArtifactEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.FilePathListing", b =>
{
b.HasOne("OpenArchival.DataAccess.ArtifactEntry", "ParentArtifactEntry")
.WithMany("Files")
.HasForeignKey("ParentArtifactEntryId");
b.Navigation("ParentArtifactEntry");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactEntry", b =>
{
b.Navigation("Files");
});
modelBuilder.Entity("OpenArchival.DataAccess.ArtifactGrouping", b =>
{
b.Navigation("ChildArtifactEntries");
b.Navigation("ChildTags");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace OpenArchival.DataAccess;
public class ArchiveCategory
{
[Key]
public int? Id { get; set; }
public required string Name { get; set; }
public string? Description { get; set; }
public required string FieldSeparator { get; set; } = "-";
public List<string> FieldNames { get; set; } = [];
public List<string> FieldDescriptions { get; set; } = [];
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenArchival.DataAccess;
public class ArtifactDefect
{
[Key]
public required int Id { get; set; }
public required string Description { get; set; }
}

View File

@@ -0,0 +1,53 @@
using System.ComponentModel.DataAnnotations;
namespace OpenArchival.DataAccess;
public class ArtifactEntry
{
[Key]
public required int Id { get; set; }
/// <summary>
/// This value gets appended on the end of the contianing ArtifactGrouping's
/// Category value
/// </summary>
public string? ArtifactIdentifier
{
get
{
return (ParentArtifactGrouping is not null)
? ModelHelpers.MakeIdentifier(ParentArtifactGrouping.IdentifierFields.Values, ParentArtifactGrouping.Category.FieldSeparator, ArtifactNumber)
: null;
}
}
public string? ArtifactNumber { get; set; }
public required string Title { get; set; }
public string? Description { get; set; }
public required ArtifactStorageLocation StorageLocation { get; set; }
public List<ArtifactEntryTag>? Tags { get; set; }
public List<string>? ListedNames { get; set; }
public List<DateTime>? AssociatedDates { get; set; }
public List<string>? Defects { get; set; }
public List<string>? Links { get; set; }
public ArtifactGrouping? ParentArtifactGrouping { get; set; }
public required List<FilePathListing> Files { get; set; }
/// <summary>
/// Maps the file name to the textual contents of the file
/// </summary>
public Dictionary<string, string>? FileTextContent { get; set; } = null;
public bool IsPubliclyVisible { get; set; }
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenArchival.DataAccess;
public class ArtifactEntryTag
{
[Key]
public int Id { get; set; }
public required string Name { get; set; }
public List<ArtifactEntry>? ArtifactEntries { get; set; }
}

View File

@@ -0,0 +1,75 @@
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class ArtifactGrouping
{
[Key]
public required int Id { get; set; }
public string? ArtifactGroupingIdentifier
{
get
{
return ModelHelpers.MakeIdentifier(_identifierFields.Values, Category.FieldSeparator, null);
}
}
public required ArchiveCategory Category { get; set; }
private IdentifierFields _identifierFields;
public required IdentifierFields IdentifierFields {
get => _identifierFields;
set
{
if (value.Values.Count != Category.FieldNames.Count)
{
throw new ArgumentException(nameof(IdentifierFields), $"The number of field values must be equal to the field count of the {nameof(ArchiveCategory)}");
}
_identifierFields = value;
}
}
public required List<ArtifactEntry> ChildArtifactEntries { get; set; } = new();
public required string Title { get; set; }
public string? Description { get; set; }
public string? Type { get; set; }
public List<ArtifactGrouping>? RelatedArtifactGroupings { get; set; }
public bool IsPublicallyVisible { get; set; }
public IEnumerable<ArtifactEntryTag> ChildTags
{
get
{
HashSet<ArtifactEntryTag> seenTags = [];
for (int index = 0; index < ChildArtifactEntries.Count; ++index)
{
// Get the tags for this entry, skip if no tags
List<ArtifactEntryTag>? tags = ChildArtifactEntries[index].Tags;
if (tags is null)
{
continue;
}
// Only yield a tag if we have not yielded it yet
foreach (ArtifactEntryTag tag in tags)
{
if (seenTags.Contains(tag))
{
continue;
}
seenTags.Add(tag);
yield return tag;
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;
namespace OpenArchival.DataAccess;
public class ArtifactStorageLocation
{
[Key]
public int Id { get; set; }
public required string Location { get; set; }
}

View File

@@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;
namespace OpenArchival.DataAccess;
public class ArtifactType
{
[Key]
public int Id { get; set; }
public required string Name { get; set; }
}

View File

@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
namespace OpenArchival.DataAccess;
public class FilePathListing
{
[Key]
public int Id { get; set; }
public ArtifactEntry? ParentArtifactEntry { get; set; }
public int? ParentArtifactEntryId { get; set; }
public required string OriginalName { get; set; }
public required string Path { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace OpenArchival.DataAccess;
public class IdentifierFields
{
public List<string> Values { get; set; } = [];
}

View File

@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
namespace OpenArchival.DataAccess;
public class ListedName
{
[Key]
public required int Id { get; set; }
public required ArtifactEntry ParentArtifactEntry { get; set; }
public string? Title { get; set; }
public required string FirstName { get; set; }
public required string LastName { get; set; }
}

View File

@@ -0,0 +1,11 @@
namespace OpenArchival.DataAccess;
public class ModelHelpers
{
public static string? MakeIdentifier(List<string>? values, string fieldSeperator, string? archiveEntryNumber)
{
if (values is null || values.Count == 0) return null;
return (archiveEntryNumber is not null) ? $"{string.Join(fieldSeperator, values)}{archiveEntryNumber}" : string.Join(fieldSeperator, values);
}
}

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>699b0057-1557-4ee6-a42f-747e6cc9d2c0</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.5.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.7" />
<PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.7" />
<PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenArchival.DataAccess;
static class Program
{
public static void Main(string[] args)
{
// In Program.cs
var builder = WebApplication.CreateBuilder(args);
// Retrieve the connection string from appsettings.json
var connectionString = builder.Configuration.GetConnectionString("PostgresConnection");
// Add the DbContext to the dependency injection container
builder.Services.AddDbContext<ArchiveDbContext>(options =>
options.UseNpgsql(connectionString));
var app = builder.Build();
app.Run();
}
};

View File

@@ -0,0 +1,12 @@
{
"profiles": {
"OpenArchival.DataAccess": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:52509;http://localhost:52510"
}
}
}

View File

@@ -0,0 +1,12 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
},
"postgresql1": {
"type": "postgresql",
"connectionId": "ConnectionStrings:DatabaseConnection",
"dynamicId": null
}
}
}

View File

@@ -0,0 +1,16 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
},
"postgresql1": {
"containerPorts": "5432:5432",
"secretStore": "LocalSecretsFile",
"containerName": "postgresql",
"containerImage": "postgres",
"type": "postgresql.container",
"connectionId": "ConnectionStrings:DatabaseConnection",
"dynamicId": null
}
}
}

View File

@@ -0,0 +1,13 @@
{
"dependencies": {
"postgresql1": {
"restored": true,
"restoreTime": "2025-08-01T13:34:48.1334288Z"
},
"secrets1": {
"restored": true,
"restoreTime": "2025-08-01T13:34:47.8718098Z"
}
},
"parameters": {}
}

View File

@@ -0,0 +1,80 @@
using Microsoft.EntityFrameworkCore;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class ArchiveCategoryProvider : IArchiveCategoryProvider
{
private Microsoft.EntityFrameworkCore.IDbContextFactory<ArchiveDbContext> _dbFactory;
private ILogger _logger;
[SetsRequiredMembers]
public ArchiveCategoryProvider(Microsoft.EntityFrameworkCore.IDbContextFactory<ArchiveDbContext> dbFactory, ILogger<ArchiveCategoryProvider> logger)
{
_dbFactory = dbFactory;
_logger = logger;
}
public async Task CreateCategoryAsync(ArchiveCategory category)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArchiveCategories.Add(category);
await context.SaveChangesAsync();
}
public async Task UpdateCategoryAsync(ArchiveCategory category)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArchiveCategories.Update(category);
await context.SaveChangesAsync();
}
public async Task DeleteCategoryAsync(ArchiveCategory category)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArchiveCategories.Remove(category);
await context.SaveChangesAsync();
}
public async Task<List<ArchiveCategory>?> GetArchiveCategory(string categoryName)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArchiveCategories.Where(a => a.Name == categoryName).ToListAsync();
}
public async Task<ArchiveCategory?> GetArchiveCategory(int id)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArchiveCategories.Where(a => a.Id == id).FirstOrDefaultAsync();
}
public async Task<List<ArchiveCategory>?> GetAllArchiveCategories()
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArchiveCategories.ToListAsync();
}
public async Task<List<ArchiveCategory>?> Search(string query)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArchiveCategories
.Where(p => p.Name.ToLower().Contains(query.ToLower())).ToListAsync();
}
public async Task<List<ArchiveCategory>?> Top(int count)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArchiveCategories
.OrderBy(p => p.Name)
.Take(count)
.ToListAsync();
}
}

View File

@@ -0,0 +1,73 @@
using Microsoft.EntityFrameworkCore;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class ArchiveEntryTagProvider : IArchiveEntryTagProvider
{
private readonly IDbContextFactory<ArchiveDbContext> _dbFactory;
private readonly ILogger<ArchiveEntryTagProvider> _logger;
[SetsRequiredMembers]
public ArchiveEntryTagProvider(IDbContextFactory<ArchiveDbContext> context, ILogger<ArchiveEntryTagProvider> logger)
{
_dbFactory = context;
_logger = logger;
}
public async Task<ArtifactEntryTag?> GetEntryTagAsync(int id)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactEntryTags.Where(t => t.Id == id).FirstOrDefaultAsync();
}
public async Task<List<ArtifactEntryTag>?> GetEntryTagAsync(string name)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactEntryTags.Where(t => t.Name == name).ToListAsync();
}
public async Task UpdateEntryTagAsync(ArtifactEntryTag entryTag)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactEntryTags.Update(entryTag);
await context.SaveChangesAsync();
}
public async Task CreateEntryTagAsync(ArtifactEntryTag entryTag)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactEntryTags.Add(entryTag);
await context.SaveChangesAsync();
}
public async Task DeleteEntryTagAsync(ArtifactEntryTag entryTag)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactEntryTags.Remove(entryTag);
await context.SaveChangesAsync();
}
public async Task<List<ArtifactEntryTag>?> Search(string query)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactEntryTags
.Where(p => p.Name.ToLower().Contains(query.ToLower())).ToListAsync();
}
public async Task<List<ArtifactEntryTag>?> Top(int count)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactEntryTags
.OrderBy(p => p.Name)
.Take(count)
.ToListAsync();
}
}

View File

@@ -0,0 +1,72 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class ArtifactDefectProvider : IArtifactDefectProvider
{
private readonly IDbContextFactory<ArchiveDbContext> _dbFactory;
private readonly ILogger<ArtifactDefectProvider> _logger;
[SetsRequiredMembers]
public ArtifactDefectProvider(IDbContextFactory<ArchiveDbContext> context, ILogger<ArtifactDefectProvider> logger)
{
_dbFactory = context;
_logger = logger;
}
public async Task<ArtifactDefect?> GetDefectAsync(int id)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactDefects.Where(d => d.Id == id).FirstOrDefaultAsync();
}
public async Task<List<ArtifactDefect>?> GetDefectAsync(string description)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactDefects.Where(d => d.Description == description).ToListAsync();
}
public async Task UpdateDefectAsync(ArtifactDefect artifactDefect)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactDefects.Update(artifactDefect);
await context.SaveChangesAsync();
}
public async Task CreateDefectAsync(ArtifactDefect artifactDefect)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactDefects.Add(artifactDefect);
await context.SaveChangesAsync();
}
public async Task DeleteDefectAsync(ArtifactDefect artifactDefect)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactDefects.Remove(artifactDefect);
await context.SaveChangesAsync();
}
public async Task<List<ArtifactDefect>?> Search(string query)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactDefects
.Where(p => p.Description.ToLower().Contains(query.ToLower())).ToListAsync();
}
public async Task<List<ArtifactDefect>?> Top(int count)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactDefects
.OrderBy(p => p.Description)
.Take(count)
.ToListAsync();
}
}

View File

@@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class ArtifactGroupingProvider : IArtifactGroupingProvider
{
private readonly ArchiveDbContext _context;
private readonly ILogger<ArtifactGroupingProvider> _logger;
[SetsRequiredMembers]
public ArtifactGroupingProvider(ArchiveDbContext context, ILogger<ArtifactGroupingProvider> logger)
{
_context = context;
_logger = logger;
}
public async Task<ArtifactGrouping?> GetGroupingAsync(int id)
{
return await _context.ArtifactGroupings.Where(g => g.Id == id).FirstOrDefaultAsync();
}
public async Task<ArtifactGrouping?> GetGroupingAsync(string artifactGroupingIdentifier)
{
return await _context.ArtifactGroupings.Where(g => g.ArtifactGroupingIdentifier == artifactGroupingIdentifier).FirstOrDefaultAsync();
}
public async Task CreateGroupingAsync(ArtifactGrouping grouping)
{
_context.ArtifactGroupings.Add(grouping);
await _context.SaveChangesAsync();
}
public async Task UpdateGroupingAsync(ArtifactGrouping grouping)
{
_context.ArtifactGroupings.Update(grouping);
await _context.SaveChangesAsync();
}
public async Task DeleteGroupingAsync(ArtifactGrouping grouping)
{
_context.ArtifactGroupings.Remove(grouping);
await _context.SaveChangesAsync();
}
}

View File

@@ -0,0 +1,84 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
namespace OpenArchival.DataAccess;
public class ArtifactStorageLocationProvider : IArtifactStorageLocationProvider
{
private readonly IDbContextFactory<ArchiveDbContext> _dbFactory;
private readonly ILogger _logger;
[SetsRequiredMembers]
public ArtifactStorageLocationProvider(IDbContextFactory<ArchiveDbContext> dbFactory, ILogger<ArtifactStorageLocationProvider> logger)
{
_dbFactory = dbFactory;
_logger = logger;
}
public async Task CreateArtifactStorageLocationAsync(ArtifactStorageLocation location)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactStorageLocations.Add(location);
await context.SaveChangesAsync();
}
public async Task UpdateArtifactStorageLocationAsync(ArtifactStorageLocation location)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactStorageLocations.Update(location);
await context.SaveChangesAsync();
}
public async Task DeleteArtifactStorageLocationAsync(ArtifactStorageLocation location)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactStorageLocations.Remove(location);
await context.SaveChangesAsync();
}
public async Task<List<ArtifactStorageLocation>?> GetArtifactStorageLocation(string locationName)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactStorageLocations.Where(a => a.Location == locationName).ToListAsync();
}
public async Task<ArtifactStorageLocation?> GetArtifactStorageLocation(int id)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactStorageLocations.Where(a => a.Id == id).FirstOrDefaultAsync();
}
public async Task<List<ArtifactStorageLocation>?> GetAllArtifactStorageLocations()
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactStorageLocations.ToListAsync();
}
public async Task<List<ArtifactStorageLocation>?> Search(string query)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactStorageLocations
.Where(p => p.Location.ToLower().Contains(query.ToLower())).ToListAsync();
}
public async Task<List<ArtifactStorageLocation>?> Top(int count)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactStorageLocations
.OrderBy(p => p.Location)
.Take(count)
.ToListAsync();
}
}

View File

@@ -0,0 +1,74 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class ArtifactTypeProvider : IArtifactTypeProvider
{
private readonly IDbContextFactory<ArchiveDbContext> _dbFactory;
private readonly ILogger<ArtifactTypeProvider> _logger;
[SetsRequiredMembers]
public ArtifactTypeProvider(IDbContextFactory<ArchiveDbContext> dbFactory, ILogger<ArtifactTypeProvider> logger)
{
_dbFactory = dbFactory;
_logger = logger;
}
public async Task CreateArtifactTypeAsync(ArtifactType artifactType)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactTypes.Add(artifactType);
await context.SaveChangesAsync();
}
public async Task UpdateArtifactTypeAsync(ArtifactType artifactType)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactTypes.Update(artifactType);
await context.SaveChangesAsync();
}
public async Task DeleteArtifactTypeAsync(ArtifactType artifactType)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactTypes.Remove(artifactType);
await context.SaveChangesAsync();
}
public async Task<List<ArtifactType>?> GetArtifactType(string name)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactTypes.Where(a => a.Name == name).ToListAsync();
}
public async Task<ArtifactType?> GetArtifactType(int id)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactTypes.FirstOrDefaultAsync(a => a.Id == id);
}
public async Task<List<ArtifactType>?> GetAllArtifactTypes()
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactTypes.ToListAsync();
}
public async Task<List<ArtifactType>?> Search(string query)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactTypes
.Where(p => p.Name.ToLower().Contains(query.ToLower()))
.ToListAsync();
}
public async Task<List<ArtifactType>?> Top(int count)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactTypes
.OrderBy(p => p.Name)
.Take(count)
.ToListAsync();
}
}

View File

@@ -0,0 +1,61 @@
using Microsoft.EntityFrameworkCore;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class FilePathListingProvider : IFilePathListingProvider
{
private readonly ArchiveDbContext _context;
private readonly ILogger<FilePathListingProvider> _logger;
[SetsRequiredMembers]
public FilePathListingProvider(ArchiveDbContext context, ILogger<FilePathListingProvider> logger)
{
_context = context;
_logger = logger;
}
public async Task<FilePathListing?> GetFilePathListingAsync(int id)
{
return await _context.ArtifactFilePaths.Where(f => f.Id == id).FirstOrDefaultAsync();
}
public async Task<FilePathListing?> GetFilePathListingByPathAsync(string path)
{
return await _context.ArtifactFilePaths.Where(f => f.Path == path).FirstOrDefaultAsync();
}
public async Task CreateFilePathListingAsync(FilePathListing filePathListing)
{
_context.ArtifactFilePaths.Add(filePathListing);
await _context.SaveChangesAsync();
}
public async Task UpdateFilePathListingAsync(FilePathListing filePathListing)
{
_context.ArtifactFilePaths.Update(filePathListing);
await _context.SaveChangesAsync();
}
public async Task DeleteFilePathListingAsync(FilePathListing filePathListing)
{
_context.ArtifactFilePaths.Remove(filePathListing);
await _context.SaveChangesAsync();
}
public async Task<bool> DeleteFilePathListingAsync(string originalFileName, string diskPath)
{
var listingToDelete = await _context.ArtifactFilePaths
.Where(p => p.OriginalName == originalFileName)
.Where(p => p.Path == diskPath)
.FirstOrDefaultAsync();
if (listingToDelete == null)
{
return false;
}
_context.RemoveRange(listingToDelete);
return true;
}
}

View File

@@ -0,0 +1,21 @@
namespace OpenArchival.DataAccess;
public interface IArchiveCategoryProvider
{
public Task CreateCategoryAsync(ArchiveCategory category);
public Task UpdateCategoryAsync(ArchiveCategory category);
public Task DeleteCategoryAsync(ArchiveCategory category);
public Task<ArchiveCategory?> GetArchiveCategory(int id);
public Task<List<ArchiveCategory>?> GetArchiveCategory(string categoryName);
public Task<List<ArchiveCategory>?> GetAllArchiveCategories();
public Task<List<ArchiveCategory>?> Search(string query);
public Task<List<ArchiveCategory>?> Top(int count);
}

View File

@@ -0,0 +1,18 @@
namespace OpenArchival.DataAccess;
public interface IArchiveEntryTagProvider
{
public Task<ArtifactEntryTag?> GetEntryTagAsync(int id);
public Task<List<ArtifactEntryTag>?> GetEntryTagAsync(string name);
public Task UpdateEntryTagAsync(ArtifactEntryTag entryTag);
public Task CreateEntryTagAsync(ArtifactEntryTag entryTag);
public Task DeleteEntryTagAsync(ArtifactEntryTag entryTag);
public Task<List<ArtifactEntryTag>?> Search(string query);
public Task<List<ArtifactEntryTag>?> Top(int count);
}

View File

@@ -0,0 +1,12 @@
namespace OpenArchival.DataAccess;
public interface IArtifactDefectProvider
{
public Task<ArtifactDefect?> GetDefectAsync(int id);
public Task<List<ArtifactDefect>?> GetDefectAsync(string description);
public Task UpdateDefectAsync(ArtifactDefect artifactDefect);
public Task CreateDefectAsync(ArtifactDefect artifactDefect);
public Task DeleteDefectAsync(ArtifactDefect artifactDefect);
public Task<List<ArtifactDefect>?> Search(string query);
public Task<List<ArtifactDefect>?> Top(int count);
}

View File

@@ -0,0 +1,10 @@
namespace OpenArchival.DataAccess;
public interface IArtifactGroupingProvider
{
Task<ArtifactGrouping?> GetGroupingAsync(int id);
Task<ArtifactGrouping?> GetGroupingAsync(string artifactGroupingIdentifier);
Task CreateGroupingAsync(ArtifactGrouping grouping);
Task UpdateGroupingAsync(ArtifactGrouping grouping);
Task DeleteGroupingAsync(ArtifactGrouping grouping);
}

View File

@@ -0,0 +1,13 @@
namespace OpenArchival.DataAccess;
public interface IArtifactStorageLocationProvider
{
Task CreateArtifactStorageLocationAsync(ArtifactStorageLocation location);
Task UpdateArtifactStorageLocationAsync(ArtifactStorageLocation location);
Task DeleteArtifactStorageLocationAsync(ArtifactStorageLocation location);
Task<List<ArtifactStorageLocation>?> GetArtifactStorageLocation(string locationName);
Task<ArtifactStorageLocation?> GetArtifactStorageLocation(int id);
Task<List<ArtifactStorageLocation>?> GetAllArtifactStorageLocations();
Task<List<ArtifactStorageLocation>?> Search(string query);
Task<List<ArtifactStorageLocation>?> Top(int count);
}

View File

@@ -0,0 +1,13 @@
namespace OpenArchival.DataAccess;
public interface IArtifactTypeProvider
{
Task CreateArtifactTypeAsync(ArtifactType artifactType);
Task UpdateArtifactTypeAsync(ArtifactType artifactType);
Task DeleteArtifactTypeAsync(ArtifactType artifactType);
Task<List<ArtifactType>?> GetArtifactType(string name);
Task<ArtifactType?> GetArtifactType(int id);
Task<List<ArtifactType>?> GetAllArtifactTypes();
Task<List<ArtifactType>?> Search(string query);
Task<List<ArtifactType>?> Top(int count);
}

View File

@@ -0,0 +1,11 @@
namespace OpenArchival.DataAccess;
public interface IFilePathListingProvider
{
Task<FilePathListing?> GetFilePathListingAsync(int id);
Task<FilePathListing?> GetFilePathListingByPathAsync(string path);
Task CreateFilePathListingAsync(FilePathListing filePathListing);
Task UpdateFilePathListingAsync(FilePathListing filePathListing);
Task DeleteFilePathListingAsync(FilePathListing filePathListing);
public Task<bool> DeleteFilePathListingAsync(string originalFileName, string diskPath);
}

View File

@@ -0,0 +1,12 @@
namespace OpenArchival.DataAccess;
public interface IListedNameProvider
{
Task<ListedName?> GetAssociatedNameAsync(int id);
Task<List<ListedName>?> GetAssociatedNamesAsync(string firstName, string lastName);
Task CreateAssociatedNameAsync(ListedName associatedName);
Task UpdateAssociatedNameAsync(ListedName associatedName);
Task DeleteAssociatedNameAsync(ListedName associatedName);
public Task<List<ListedName>?> Search(string query);
public Task<List<ListedName>?> Top(int count);
}

View File

@@ -0,0 +1,79 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;
namespace OpenArchival.DataAccess;
public class ListedNameProvider : IListedNameProvider
{
private readonly IDbContextFactory<ArchiveDbContext> _dbFactory;
private readonly ILogger<ListedNameProvider> _logger;
[SetsRequiredMembers]
public ListedNameProvider(IDbContextFactory<ArchiveDbContext> context, ILogger<ListedNameProvider> logger)
{
_dbFactory = context;
_logger = logger;
}
public async Task<ListedName?> GetAssociatedNameAsync(int id)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactAssociatedNames.Where(n => n.Id == id).FirstOrDefaultAsync();
}
public async Task<List<ListedName>?> GetAssociatedNamesAsync(string firstName, string lastName)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactAssociatedNames
.Where(n => n.FirstName == firstName && n.LastName == lastName)
.ToListAsync();
}
public async Task CreateAssociatedNameAsync(ListedName associatedName)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactAssociatedNames.Add(associatedName);
await context.SaveChangesAsync();
}
public async Task UpdateAssociatedNameAsync(ListedName associatedName)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactAssociatedNames.Update(associatedName);
await context.SaveChangesAsync();
}
public async Task DeleteAssociatedNameAsync(ListedName associatedName)
{
await using var context = await _dbFactory.CreateDbContextAsync();
context.ArtifactAssociatedNames.Remove(associatedName);
await context.SaveChangesAsync();
}
public async Task<List<ListedName>?> Search(string query)
{
await using var context = await _dbFactory.CreateDbContextAsync();
var lowerCaseQuery = query.ToLower();
return await context.ArtifactAssociatedNames
.Where(p => (p.FirstName + " " + p.LastName).ToLower().Contains(lowerCaseQuery))
.ToListAsync();
}
public async Task<List<ListedName>?> Top(int count)
{
await using var context = await _dbFactory.CreateDbContextAsync();
return await context.ArtifactAssociatedNames
.OrderBy(p => p.FirstName)
.Take(count)
.ToListAsync();
}
}

View File

@@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"PostgresConnection": "Host=localhost;Database=postgres;Username=postgres;Password="
}
}

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "9.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1 @@
{"Version":1,"ManifestType":"Build","Endpoints":[]}

View File

@@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"PostgresConnection": "Host=localhost;Database=postgres;Username=postgres;Password="
}
}

Some files were not shown because too many files have changed in this diff Show More