From 0d758c6cd118641e86e6a7ddd7285be916cdb2d8 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Fri, 11 Aug 2023 14:41:40 +1000 Subject: Updated database schema to use separate tables --- HyperBooruContext.cs | 8 + Migrations/20230809044429_Initial.Designer.cs | 206 ----------------------- Migrations/20230809044429_Initial.cs | 118 ------------- Migrations/20230811002826_Initial.Designer.cs | 221 +++++++++++++++++++++++++ Migrations/20230811002826_Initial.cs | 180 ++++++++++++++++++++ Migrations/HyperBooruDbContextModelSnapshot.cs | 39 +++-- 6 files changed, 436 insertions(+), 336 deletions(-) delete mode 100644 Migrations/20230809044429_Initial.Designer.cs delete mode 100644 Migrations/20230809044429_Initial.cs create mode 100644 Migrations/20230811002826_Initial.Designer.cs create mode 100644 Migrations/20230811002826_Initial.cs diff --git a/HyperBooruContext.cs b/HyperBooruContext.cs index 8223ee3..fecbc4c 100644 --- a/HyperBooruContext.cs +++ b/HyperBooruContext.cs @@ -21,4 +21,12 @@ public class HyperBooruDbContext : DbContext { var path = Path.Join(config.DataPath, "HyperBooru.db"); options.UseSqlite($"Data Source = {config.DbPath}"); } + + protected override void OnModelCreating(ModelBuilder modelBuilder) { + modelBuilder.Entity().ToTable("Objects"); + modelBuilder.Entity().ToTable("TagDefinitions"); + modelBuilder.Entity().ToTable("Tags"); + modelBuilder.Entity().ToTable("Media"); + modelBuilder.Entity().ToTable("UploadedFiles"); + } } \ No newline at end of file diff --git a/Migrations/20230809044429_Initial.Designer.cs b/Migrations/20230809044429_Initial.Designer.cs deleted file mode 100644 index 78a0ca3..0000000 --- a/Migrations/20230809044429_Initial.Designer.cs +++ /dev/null @@ -1,206 +0,0 @@ -// -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(HyperBooruDbContext))] - [Migration("20230809044429_Initial")] - partial class Initial - { - /// - 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.DbObject", b => - { - b.Property("ObjectId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Discriminator") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Guid") - .HasColumnType("TEXT"); - - b.Property("ObjectType") - .HasColumnType("INTEGER"); - - b.HasKey("ObjectId"); - - b.HasIndex("Guid"); - - b.ToTable("Objects"); - - b.HasDiscriminator("Discriminator").HasValue("DbObject"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("HyperBooru.DbUploadedFile", b => - { - b.Property("UploadedFileId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CreateTime") - .HasColumnType("TEXT"); - - b.Property("Filename") - .HasColumnType("TEXT"); - - b.Property("LastAccessTime") - .HasColumnType("TEXT"); - - b.Property("LastWriteTime") - .HasColumnType("TEXT"); - - b.Property("MediaObjectId") - .HasColumnType("INTEGER"); - - b.Property("OriginalChecksum") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("UploadTime") - .HasColumnType("TEXT"); - - b.HasKey("UploadedFileId"); - - b.HasIndex("MediaObjectId"); - - b.ToTable("UploadedFiles"); - }); - - modelBuilder.Entity("HyperBooru.DbMedia", b => - { - b.HasBaseType("HyperBooru.DbObject"); - - b.Property("Checksum") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LongDescription") - .HasColumnType("TEXT"); - - b.Property("MimeType") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ShortDescription") - .HasColumnType("TEXT"); - - b.HasDiscriminator().HasValue("DbMedia"); - }); - - modelBuilder.Entity("HyperBooru.DbTag", b => - { - b.HasBaseType("HyperBooru.DbObject"); - - b.Property("CreateTime") - .HasColumnType("TEXT"); - - b.Property("TagDefinitionObjectId") - .HasColumnType("INTEGER"); - - b.Property("TargetObjectId") - .HasColumnType("INTEGER"); - - b.HasIndex("TagDefinitionObjectId"); - - b.HasIndex("TargetObjectId"); - - b.HasDiscriminator().HasValue("DbTag"); - }); - - modelBuilder.Entity("HyperBooru.DbTagDefinition", b => - { - b.HasBaseType("HyperBooru.DbObject"); - - b.Property("DbTagDefinitionObjectId") - .HasColumnType("INTEGER"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Namespace") - .HasColumnType("TEXT"); - - b.Property("Source") - .HasColumnType("INTEGER"); - - b.HasIndex("DbTagDefinitionObjectId"); - - b.HasDiscriminator().HasValue("DbTagDefinition"); - }); - - modelBuilder.Entity("HyperBooru.DbUploadedFile", b => - { - b.HasOne("HyperBooru.DbMedia", "Media") - .WithMany("UploadedFiles") - .HasForeignKey("MediaObjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Media"); - }); - - modelBuilder.Entity("HyperBooru.DbTag", b => - { - b.HasOne("HyperBooru.DbTagDefinition", "TagDefinition") - .WithMany() - .HasForeignKey("TagDefinitionObjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("HyperBooru.DbObject", "Target") - .WithMany("Tags") - .HasForeignKey("TargetObjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("TagDefinition"); - - b.Navigation("Target"); - }); - - modelBuilder.Entity("HyperBooru.DbTagDefinition", b => - { - b.HasOne("HyperBooru.DbTagDefinition", null) - .WithMany("ImplicitTags") - .HasForeignKey("DbTagDefinitionObjectId"); - }); - - modelBuilder.Entity("HyperBooru.DbObject", b => - { - b.Navigation("Tags"); - }); - - modelBuilder.Entity("HyperBooru.DbMedia", b => - { - b.Navigation("UploadedFiles"); - }); - - modelBuilder.Entity("HyperBooru.DbTagDefinition", b => - { - b.Navigation("ImplicitTags"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Migrations/20230809044429_Initial.cs b/Migrations/20230809044429_Initial.cs deleted file mode 100644 index 0126c13..0000000 --- a/Migrations/20230809044429_Initial.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace HyperBooru.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Objects", - columns: table => new - { - ObjectId = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Guid = table.Column(type: "TEXT", nullable: false), - ObjectType = table.Column(type: "INTEGER", nullable: false), - Discriminator = table.Column(type: "TEXT", nullable: false), - Checksum = table.Column(type: "TEXT", nullable: true), - MimeType = table.Column(type: "TEXT", nullable: true), - ShortDescription = table.Column(type: "TEXT", nullable: true), - LongDescription = table.Column(type: "TEXT", nullable: true), - TagDefinitionObjectId = table.Column(type: "INTEGER", nullable: true), - CreateTime = table.Column(type: "TEXT", nullable: true), - TargetObjectId = table.Column(type: "INTEGER", nullable: true), - Source = table.Column(type: "INTEGER", nullable: true), - Namespace = table.Column(type: "TEXT", nullable: true), - Name = table.Column(type: "TEXT", nullable: true), - DbTagDefinitionObjectId = table.Column(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Objects", x => x.ObjectId); - table.ForeignKey( - name: "FK_Objects_Objects_DbTagDefinitionObjectId", - column: x => x.DbTagDefinitionObjectId, - principalTable: "Objects", - principalColumn: "ObjectId"); - table.ForeignKey( - name: "FK_Objects_Objects_TagDefinitionObjectId", - column: x => x.TagDefinitionObjectId, - principalTable: "Objects", - principalColumn: "ObjectId", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Objects_Objects_TargetObjectId", - column: x => x.TargetObjectId, - principalTable: "Objects", - principalColumn: "ObjectId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UploadedFiles", - columns: table => new - { - UploadedFileId = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - OriginalChecksum = table.Column(type: "TEXT", nullable: false), - Filename = table.Column(type: "TEXT", nullable: true), - UploadTime = table.Column(type: "TEXT", nullable: false), - LastAccessTime = table.Column(type: "TEXT", nullable: true), - LastWriteTime = table.Column(type: "TEXT", nullable: true), - CreateTime = table.Column(type: "TEXT", nullable: true), - MediaObjectId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UploadedFiles", x => x.UploadedFileId); - table.ForeignKey( - name: "FK_UploadedFiles_Objects_MediaObjectId", - column: x => x.MediaObjectId, - principalTable: "Objects", - principalColumn: "ObjectId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Objects_DbTagDefinitionObjectId", - table: "Objects", - column: "DbTagDefinitionObjectId"); - - migrationBuilder.CreateIndex( - name: "IX_Objects_Guid", - table: "Objects", - column: "Guid"); - - migrationBuilder.CreateIndex( - name: "IX_Objects_TagDefinitionObjectId", - table: "Objects", - column: "TagDefinitionObjectId"); - - migrationBuilder.CreateIndex( - name: "IX_Objects_TargetObjectId", - table: "Objects", - column: "TargetObjectId"); - - migrationBuilder.CreateIndex( - name: "IX_UploadedFiles_MediaObjectId", - table: "UploadedFiles", - column: "MediaObjectId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "UploadedFiles"); - - migrationBuilder.DropTable( - name: "Objects"); - } - } -} diff --git a/Migrations/20230811002826_Initial.Designer.cs b/Migrations/20230811002826_Initial.Designer.cs new file mode 100644 index 0000000..9db9176 --- /dev/null +++ b/Migrations/20230811002826_Initial.Designer.cs @@ -0,0 +1,221 @@ +// +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(HyperBooruDbContext))] + [Migration("20230811002826_Initial")] + partial class Initial + { + /// + 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.DbObject", b => + { + b.Property("ObjectId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Guid") + .HasColumnType("TEXT"); + + b.Property("ObjectType") + .HasColumnType("INTEGER"); + + b.HasKey("ObjectId"); + + b.HasIndex("Guid"); + + b.ToTable("Objects", (string)null); + + b.UseTptMappingStrategy(); + }); + + modelBuilder.Entity("HyperBooru.DbUploadedFile", b => + { + b.Property("UploadedFileId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("Filename") + .HasColumnType("TEXT"); + + b.Property("LastAccessTime") + .HasColumnType("TEXT"); + + b.Property("LastWriteTime") + .HasColumnType("TEXT"); + + b.Property("MediaObjectId") + .HasColumnType("INTEGER"); + + b.Property("OriginalChecksum") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UploadTime") + .HasColumnType("TEXT"); + + b.HasKey("UploadedFileId"); + + b.HasIndex("MediaObjectId"); + + b.ToTable("UploadedFiles", (string)null); + }); + + modelBuilder.Entity("HyperBooru.DbMedia", b => + { + b.HasBaseType("HyperBooru.DbObject"); + + b.Property("Checksum") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LongDescription") + .HasColumnType("TEXT"); + + b.Property("MimeType") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ShortDescription") + .HasColumnType("TEXT"); + + b.ToTable("Media", (string)null); + }); + + modelBuilder.Entity("HyperBooru.DbTag", b => + { + b.HasBaseType("HyperBooru.DbObject"); + + b.Property("CreateTime") + .HasColumnType("TEXT"); + + b.Property("TagDefinitionObjectId") + .HasColumnType("INTEGER"); + + b.Property("TargetObjectId") + .HasColumnType("INTEGER"); + + b.HasIndex("TagDefinitionObjectId"); + + b.HasIndex("TargetObjectId"); + + b.ToTable("Tags", (string)null); + }); + + modelBuilder.Entity("HyperBooru.DbTagDefinition", b => + { + b.HasBaseType("HyperBooru.DbObject"); + + b.Property("DbTagDefinitionObjectId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Namespace") + .HasColumnType("TEXT"); + + b.Property("Source") + .HasColumnType("INTEGER"); + + b.HasIndex("DbTagDefinitionObjectId"); + + b.ToTable("TagDefinitions", (string)null); + }); + + modelBuilder.Entity("HyperBooru.DbUploadedFile", b => + { + b.HasOne("HyperBooru.DbMedia", "Media") + .WithMany("UploadedFiles") + .HasForeignKey("MediaObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("HyperBooru.DbMedia", b => + { + b.HasOne("HyperBooru.DbObject", null) + .WithOne() + .HasForeignKey("HyperBooru.DbMedia", "ObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("HyperBooru.DbTag", b => + { + b.HasOne("HyperBooru.DbObject", null) + .WithOne() + .HasForeignKey("HyperBooru.DbTag", "ObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HyperBooru.DbTagDefinition", "TagDefinition") + .WithMany() + .HasForeignKey("TagDefinitionObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HyperBooru.DbObject", "Target") + .WithMany("Tags") + .HasForeignKey("TargetObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TagDefinition"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("HyperBooru.DbTagDefinition", b => + { + b.HasOne("HyperBooru.DbTagDefinition", null) + .WithMany("ImplicitTags") + .HasForeignKey("DbTagDefinitionObjectId"); + + b.HasOne("HyperBooru.DbObject", null) + .WithOne() + .HasForeignKey("HyperBooru.DbTagDefinition", "ObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("HyperBooru.DbObject", b => + { + b.Navigation("Tags"); + }); + + modelBuilder.Entity("HyperBooru.DbMedia", b => + { + b.Navigation("UploadedFiles"); + }); + + modelBuilder.Entity("HyperBooru.DbTagDefinition", b => + { + b.Navigation("ImplicitTags"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230811002826_Initial.cs b/Migrations/20230811002826_Initial.cs new file mode 100644 index 0000000..f3017e5 --- /dev/null +++ b/Migrations/20230811002826_Initial.cs @@ -0,0 +1,180 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace HyperBooru.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Objects", + columns: table => new + { + ObjectId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Guid = table.Column(type: "TEXT", nullable: false), + ObjectType = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Objects", x => x.ObjectId); + }); + + migrationBuilder.CreateTable( + name: "Media", + columns: table => new + { + ObjectId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Checksum = table.Column(type: "TEXT", nullable: false), + MimeType = table.Column(type: "TEXT", nullable: false), + ShortDescription = table.Column(type: "TEXT", nullable: true), + LongDescription = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Media", x => x.ObjectId); + table.ForeignKey( + name: "FK_Media_Objects_ObjectId", + column: x => x.ObjectId, + principalTable: "Objects", + principalColumn: "ObjectId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TagDefinitions", + columns: table => new + { + ObjectId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Source = table.Column(type: "INTEGER", nullable: false), + Namespace = table.Column(type: "TEXT", nullable: true), + Name = table.Column(type: "TEXT", nullable: false), + DbTagDefinitionObjectId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TagDefinitions", x => x.ObjectId); + table.ForeignKey( + name: "FK_TagDefinitions_Objects_ObjectId", + column: x => x.ObjectId, + principalTable: "Objects", + principalColumn: "ObjectId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TagDefinitions_TagDefinitions_DbTagDefinitionObjectId", + column: x => x.DbTagDefinitionObjectId, + principalTable: "TagDefinitions", + principalColumn: "ObjectId"); + }); + + migrationBuilder.CreateTable( + name: "UploadedFiles", + columns: table => new + { + UploadedFileId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + OriginalChecksum = table.Column(type: "TEXT", nullable: false), + Filename = table.Column(type: "TEXT", nullable: true), + UploadTime = table.Column(type: "TEXT", nullable: false), + LastAccessTime = table.Column(type: "TEXT", nullable: true), + LastWriteTime = table.Column(type: "TEXT", nullable: true), + CreateTime = table.Column(type: "TEXT", nullable: true), + MediaObjectId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UploadedFiles", x => x.UploadedFileId); + table.ForeignKey( + name: "FK_UploadedFiles_Media_MediaObjectId", + column: x => x.MediaObjectId, + principalTable: "Media", + principalColumn: "ObjectId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Tags", + columns: table => new + { + ObjectId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + TagDefinitionObjectId = table.Column(type: "INTEGER", nullable: false), + CreateTime = table.Column(type: "TEXT", nullable: false), + TargetObjectId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Tags", x => x.ObjectId); + table.ForeignKey( + name: "FK_Tags_Objects_ObjectId", + column: x => x.ObjectId, + principalTable: "Objects", + principalColumn: "ObjectId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Tags_Objects_TargetObjectId", + column: x => x.TargetObjectId, + principalTable: "Objects", + principalColumn: "ObjectId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Tags_TagDefinitions_TagDefinitionObjectId", + column: x => x.TagDefinitionObjectId, + principalTable: "TagDefinitions", + principalColumn: "ObjectId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Objects_Guid", + table: "Objects", + column: "Guid"); + + migrationBuilder.CreateIndex( + name: "IX_TagDefinitions_DbTagDefinitionObjectId", + table: "TagDefinitions", + column: "DbTagDefinitionObjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Tags_TagDefinitionObjectId", + table: "Tags", + column: "TagDefinitionObjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Tags_TargetObjectId", + table: "Tags", + column: "TargetObjectId"); + + migrationBuilder.CreateIndex( + name: "IX_UploadedFiles_MediaObjectId", + table: "UploadedFiles", + column: "MediaObjectId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Tags"); + + migrationBuilder.DropTable( + name: "UploadedFiles"); + + migrationBuilder.DropTable( + name: "TagDefinitions"); + + migrationBuilder.DropTable( + name: "Media"); + + migrationBuilder.DropTable( + name: "Objects"); + } + } +} diff --git a/Migrations/HyperBooruDbContextModelSnapshot.cs b/Migrations/HyperBooruDbContextModelSnapshot.cs index 566b66c..36f6e72 100644 --- a/Migrations/HyperBooruDbContextModelSnapshot.cs +++ b/Migrations/HyperBooruDbContextModelSnapshot.cs @@ -27,10 +27,6 @@ namespace HyperBooru.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("Discriminator") - .IsRequired() - .HasColumnType("TEXT"); - b.Property("Guid") .HasColumnType("TEXT"); @@ -41,11 +37,9 @@ namespace HyperBooru.Migrations b.HasIndex("Guid"); - b.ToTable("Objects"); - - b.HasDiscriminator("Discriminator").HasValue("DbObject"); + b.ToTable("Objects", (string)null); - b.UseTphMappingStrategy(); + b.UseTptMappingStrategy(); }); modelBuilder.Entity("HyperBooru.DbUploadedFile", b => @@ -80,7 +74,7 @@ namespace HyperBooru.Migrations b.HasIndex("MediaObjectId"); - b.ToTable("UploadedFiles"); + b.ToTable("UploadedFiles", (string)null); }); modelBuilder.Entity("HyperBooru.DbMedia", b => @@ -101,7 +95,7 @@ namespace HyperBooru.Migrations b.Property("ShortDescription") .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("DbMedia"); + b.ToTable("Media", (string)null); }); modelBuilder.Entity("HyperBooru.DbTag", b => @@ -121,7 +115,7 @@ namespace HyperBooru.Migrations b.HasIndex("TargetObjectId"); - b.HasDiscriminator().HasValue("DbTag"); + b.ToTable("Tags", (string)null); }); modelBuilder.Entity("HyperBooru.DbTagDefinition", b => @@ -143,7 +137,7 @@ namespace HyperBooru.Migrations b.HasIndex("DbTagDefinitionObjectId"); - b.HasDiscriminator().HasValue("DbTagDefinition"); + b.ToTable("TagDefinitions", (string)null); }); modelBuilder.Entity("HyperBooru.DbUploadedFile", b => @@ -157,8 +151,23 @@ namespace HyperBooru.Migrations b.Navigation("Media"); }); + modelBuilder.Entity("HyperBooru.DbMedia", b => + { + b.HasOne("HyperBooru.DbObject", null) + .WithOne() + .HasForeignKey("HyperBooru.DbMedia", "ObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + modelBuilder.Entity("HyperBooru.DbTag", b => { + b.HasOne("HyperBooru.DbObject", null) + .WithOne() + .HasForeignKey("HyperBooru.DbTag", "ObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("HyperBooru.DbTagDefinition", "TagDefinition") .WithMany() .HasForeignKey("TagDefinitionObjectId") @@ -181,6 +190,12 @@ namespace HyperBooru.Migrations b.HasOne("HyperBooru.DbTagDefinition", null) .WithMany("ImplicitTags") .HasForeignKey("DbTagDefinitionObjectId"); + + b.HasOne("HyperBooru.DbObject", null) + .WithOne() + .HasForeignKey("HyperBooru.DbTagDefinition", "ObjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("HyperBooru.DbObject", b => -- cgit v1.3