summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HBContext.cs5
-rw-r--r--Migrations/20230816233054_ImplicitTags.Designer.cs250
-rw-r--r--Migrations/20230816233054_ImplicitTags.cs123
-rw-r--r--Migrations/HBContextModelSnapshot.cs48
-rw-r--r--Tag.cs11
5 files changed, 416 insertions, 21 deletions
diff --git a/HBContext.cs b/HBContext.cs
index 17b8b3d..162a2c7 100644
--- a/HBContext.cs
+++ b/HBContext.cs
@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using HyperBooru.Services;
+using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
namespace HyperBooru;
@@ -37,5 +38,9 @@ public class HBContext : DbContext {
new() { ObjectId = -1, Source = TagSource.Internal, Name = "nsfw" },
new() { ObjectId = -2, Source = TagSource.Internal, Name = "ingest" }
});
+
+ modelBuilder.Entity<TagDefinition>()
+ .HasMany(e => e.ImplicitTags)
+ .WithMany();
}
} \ No newline at end of file
diff --git a/Migrations/20230816233054_ImplicitTags.Designer.cs b/Migrations/20230816233054_ImplicitTags.Designer.cs
new file mode 100644
index 0000000..531b14c
--- /dev/null
+++ b/Migrations/20230816233054_ImplicitTags.Designer.cs
@@ -0,0 +1,250 @@
+// <auto-generated />
+using System;
+using HyperBooru;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace HyperBooru.Migrations
+{
+ [DbContext(typeof(HBContext))]
+ [Migration("20230816233054_ImplicitTags")]
+ partial class ImplicitTags
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.10")
+ .HasAnnotation("Proxies:ChangeTracking", false)
+ .HasAnnotation("Proxies:CheckEquality", false)
+ .HasAnnotation("Proxies:LazyLoading", true);
+
+ modelBuilder.Entity("HyperBooru.HBObject", b =>
+ {
+ b.Property<int>("ObjectId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<Guid>("Guid")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ObjectId");
+
+ b.HasIndex("Guid");
+
+ b.ToTable("Objects", (string)null);
+
+ b.UseTptMappingStrategy();
+ });
+
+ modelBuilder.Entity("HyperBooru.UploadedFile", b =>
+ {
+ b.Property<int>("UploadedFileId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime?>("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Filename")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime?>("LastAccessTime")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime?>("LastWriteTime")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("MediaObjectId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("OriginalChecksum")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("UploadTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UploadedFileId");
+
+ b.HasIndex("MediaObjectId");
+
+ b.ToTable("UploadedFiles", (string)null);
+ });
+
+ modelBuilder.Entity("TagDefinitionTagDefinition", b =>
+ {
+ b.Property<int>("ImplicitTagsObjectId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagDefinitionObjectId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ImplicitTagsObjectId", "TagDefinitionObjectId");
+
+ b.HasIndex("TagDefinitionObjectId");
+
+ b.ToTable("TagDefinitionTagDefinition");
+ });
+
+ modelBuilder.Entity("HyperBooru.Media", b =>
+ {
+ b.HasBaseType("HyperBooru.HBObject");
+
+ b.Property<string>("Checksum")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("LongDescription")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("MimeType")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ShortDescription")
+ .HasColumnType("TEXT");
+
+ b.ToTable("Media", (string)null);
+ });
+
+ modelBuilder.Entity("HyperBooru.Tag", b =>
+ {
+ b.HasBaseType("HyperBooru.HBObject");
+
+ b.Property<DateTime>("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("TagDefinitionObjectId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TargetObjectId")
+ .HasColumnType("INTEGER");
+
+ b.HasIndex("TagDefinitionObjectId");
+
+ b.HasIndex("TargetObjectId");
+
+ b.ToTable("Tags", (string)null);
+ });
+
+ modelBuilder.Entity("HyperBooru.TagDefinition", b =>
+ {
+ b.HasBaseType("HyperBooru.HBObject");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Namespace")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Source")
+ .HasColumnType("INTEGER");
+
+ b.ToTable("TagDefinitions", (string)null);
+
+ b.HasData(
+ new
+ {
+ ObjectId = -1,
+ Guid = new Guid("13399c38-34b8-44a1-ac42-536bd32de96a"),
+ Name = "nsfw",
+ Source = 0
+ },
+ new
+ {
+ ObjectId = -2,
+ Guid = new Guid("8b9cd13c-422a-4958-b97e-b858ac9301db"),
+ Name = "ingest",
+ Source = 0
+ });
+ });
+
+ modelBuilder.Entity("HyperBooru.UploadedFile", b =>
+ {
+ b.HasOne("HyperBooru.Media", "Media")
+ .WithMany("UploadedFiles")
+ .HasForeignKey("MediaObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Media");
+ });
+
+ modelBuilder.Entity("TagDefinitionTagDefinition", b =>
+ {
+ b.HasOne("HyperBooru.TagDefinition", null)
+ .WithMany()
+ .HasForeignKey("ImplicitTagsObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HyperBooru.TagDefinition", null)
+ .WithMany()
+ .HasForeignKey("TagDefinitionObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("HyperBooru.Media", b =>
+ {
+ b.HasOne("HyperBooru.HBObject", null)
+ .WithOne()
+ .HasForeignKey("HyperBooru.Media", "ObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("HyperBooru.Tag", b =>
+ {
+ b.HasOne("HyperBooru.HBObject", null)
+ .WithOne()
+ .HasForeignKey("HyperBooru.Tag", "ObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HyperBooru.TagDefinition", "TagDefinition")
+ .WithMany()
+ .HasForeignKey("TagDefinitionObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HyperBooru.HBObject", "Target")
+ .WithMany("Tags")
+ .HasForeignKey("TargetObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("TagDefinition");
+
+ b.Navigation("Target");
+ });
+
+ modelBuilder.Entity("HyperBooru.TagDefinition", b =>
+ {
+ b.HasOne("HyperBooru.HBObject", null)
+ .WithOne()
+ .HasForeignKey("HyperBooru.TagDefinition", "ObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("HyperBooru.HBObject", b =>
+ {
+ b.Navigation("Tags");
+ });
+
+ modelBuilder.Entity("HyperBooru.Media", b =>
+ {
+ b.Navigation("UploadedFiles");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Migrations/20230816233054_ImplicitTags.cs b/Migrations/20230816233054_ImplicitTags.cs
new file mode 100644
index 0000000..26078d6
--- /dev/null
+++ b/Migrations/20230816233054_ImplicitTags.cs
@@ -0,0 +1,123 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace HyperBooru.Migrations
+{
+ /// <inheritdoc />
+ public partial class ImplicitTags : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_TagDefinitions_TagDefinitions_TagDefinitionObjectId",
+ table: "TagDefinitions");
+
+ migrationBuilder.DropIndex(
+ name: "IX_TagDefinitions_TagDefinitionObjectId",
+ table: "TagDefinitions");
+
+ migrationBuilder.DropColumn(
+ name: "TagDefinitionObjectId",
+ table: "TagDefinitions");
+
+ migrationBuilder.CreateTable(
+ name: "TagDefinitionTagDefinition",
+ columns: table => new
+ {
+ ImplicitTagsObjectId = table.Column<int>(type: "INTEGER", nullable: false),
+ TagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_TagDefinitionTagDefinition", x => new { x.ImplicitTagsObjectId, x.TagDefinitionObjectId });
+ table.ForeignKey(
+ name: "FK_TagDefinitionTagDefinition_TagDefinitions_ImplicitTagsObjectId",
+ column: x => x.ImplicitTagsObjectId,
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_TagDefinitionTagDefinition_TagDefinitions_TagDefinitionObjectId",
+ column: x => x.TagDefinitionObjectId,
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.UpdateData(
+ table: "Objects",
+ keyColumn: "ObjectId",
+ keyValue: -2,
+ column: "Guid",
+ value: new Guid("8b9cd13c-422a-4958-b97e-b858ac9301db"));
+
+ migrationBuilder.UpdateData(
+ table: "Objects",
+ keyColumn: "ObjectId",
+ keyValue: -1,
+ column: "Guid",
+ value: new Guid("13399c38-34b8-44a1-ac42-536bd32de96a"));
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TagDefinitionTagDefinition_TagDefinitionObjectId",
+ table: "TagDefinitionTagDefinition",
+ column: "TagDefinitionObjectId");
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "TagDefinitionTagDefinition");
+
+ migrationBuilder.AddColumn<int>(
+ name: "TagDefinitionObjectId",
+ table: "TagDefinitions",
+ type: "INTEGER",
+ nullable: true);
+
+ migrationBuilder.UpdateData(
+ table: "Objects",
+ keyColumn: "ObjectId",
+ keyValue: -2,
+ column: "Guid",
+ value: new Guid("716ac11f-135a-433c-84a7-7bdfddbec004"));
+
+ migrationBuilder.UpdateData(
+ table: "Objects",
+ keyColumn: "ObjectId",
+ keyValue: -1,
+ column: "Guid",
+ value: new Guid("cbd871cb-8790-4519-9f74-90d1e13a48a0"));
+
+ migrationBuilder.UpdateData(
+ table: "TagDefinitions",
+ keyColumn: "ObjectId",
+ keyValue: -2,
+ column: "TagDefinitionObjectId",
+ value: null);
+
+ migrationBuilder.UpdateData(
+ table: "TagDefinitions",
+ keyColumn: "ObjectId",
+ keyValue: -1,
+ column: "TagDefinitionObjectId",
+ value: null);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TagDefinitions_TagDefinitionObjectId",
+ table: "TagDefinitions",
+ column: "TagDefinitionObjectId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TagDefinitions_TagDefinitions_TagDefinitionObjectId",
+ table: "TagDefinitions",
+ column: "TagDefinitionObjectId",
+ principalTable: "TagDefinitions",
+ principalColumn: "ObjectId");
+ }
+ }
+}
diff --git a/Migrations/HBContextModelSnapshot.cs b/Migrations/HBContextModelSnapshot.cs
index 9697e16..06712a6 100644
--- a/Migrations/HBContextModelSnapshot.cs
+++ b/Migrations/HBContextModelSnapshot.cs
@@ -74,6 +74,21 @@ namespace HyperBooru.Migrations
b.ToTable("UploadedFiles", (string)null);
});
+ modelBuilder.Entity("TagDefinitionTagDefinition", b =>
+ {
+ b.Property<int>("ImplicitTagsObjectId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagDefinitionObjectId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ImplicitTagsObjectId", "TagDefinitionObjectId");
+
+ b.HasIndex("TagDefinitionObjectId");
+
+ b.ToTable("TagDefinitionTagDefinition");
+ });
+
modelBuilder.Entity("HyperBooru.Media", b =>
{
b.HasBaseType("HyperBooru.HBObject");
@@ -129,25 +144,20 @@ namespace HyperBooru.Migrations
b.Property<int>("Source")
.HasColumnType("INTEGER");
- b.Property<int?>("TagDefinitionObjectId")
- .HasColumnType("INTEGER");
-
- b.HasIndex("TagDefinitionObjectId");
-
b.ToTable("TagDefinitions", (string)null);
b.HasData(
new
{
ObjectId = -1,
- Guid = new Guid("cbd871cb-8790-4519-9f74-90d1e13a48a0"),
+ Guid = new Guid("13399c38-34b8-44a1-ac42-536bd32de96a"),
Name = "nsfw",
Source = 0
},
new
{
ObjectId = -2,
- Guid = new Guid("716ac11f-135a-433c-84a7-7bdfddbec004"),
+ Guid = new Guid("8b9cd13c-422a-4958-b97e-b858ac9301db"),
Name = "ingest",
Source = 0
});
@@ -164,6 +174,21 @@ namespace HyperBooru.Migrations
b.Navigation("Media");
});
+ modelBuilder.Entity("TagDefinitionTagDefinition", b =>
+ {
+ b.HasOne("HyperBooru.TagDefinition", null)
+ .WithMany()
+ .HasForeignKey("ImplicitTagsObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HyperBooru.TagDefinition", null)
+ .WithMany()
+ .HasForeignKey("TagDefinitionObjectId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
modelBuilder.Entity("HyperBooru.Media", b =>
{
b.HasOne("HyperBooru.HBObject", null)
@@ -205,10 +230,6 @@ namespace HyperBooru.Migrations
.HasForeignKey("HyperBooru.TagDefinition", "ObjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
-
- b.HasOne("HyperBooru.TagDefinition", null)
- .WithMany("ImplicitTags")
- .HasForeignKey("TagDefinitionObjectId");
});
modelBuilder.Entity("HyperBooru.HBObject", b =>
@@ -220,11 +241,6 @@ namespace HyperBooru.Migrations
{
b.Navigation("UploadedFiles");
});
-
- modelBuilder.Entity("HyperBooru.TagDefinition", b =>
- {
- b.Navigation("ImplicitTags");
- });
#pragma warning restore 612, 618
}
}
diff --git a/Tag.cs b/Tag.cs
index 0f7fed2..810c49c 100644
--- a/Tag.cs
+++ b/Tag.cs
@@ -1,4 +1,5 @@
-using System.ComponentModel.DataAnnotations;
+using Microsoft.EntityFrameworkCore;
+using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace HyperBooru;
@@ -9,10 +10,10 @@ public enum TagSource {
}
public class TagDefinition : HBObject {
- public TagSource Source { get; set; } = TagSource.Internal;
- public string? Namespace { get; set; }
- public string Name { get; set; }
- public virtual List<TagDefinition> ImplicitTags { get; set; } = new();
+ public TagSource Source { get; set; } = TagSource.Internal;
+ public string? Namespace { get; set; }
+ public string Name { get; set; }
+ public virtual List<TagDefinition> ImplicitTags { get; set; } = new();
}
public class Tag : HBObject {