From 5b00f23b28e3a09a4120101a8be8802d009e5d84 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Mon, 14 Aug 2023 00:29:38 +1000 Subject: Added functionality for ingest tagging and implicit tags --- Migrations/20230811002826_Initial.Designer.cs | 221 ----------------------- Migrations/20230811002826_Initial.cs | 180 ------------------- Migrations/20230812095148_Initial.Designer.cs | 239 +++++++++++++++++++++++++ Migrations/20230812095148_Initial.cs | 200 +++++++++++++++++++++ Migrations/HyperBooruDbContextModelSnapshot.cs | 18 ++ 5 files changed, 457 insertions(+), 401 deletions(-) delete mode 100644 Migrations/20230811002826_Initial.Designer.cs delete mode 100644 Migrations/20230811002826_Initial.cs create mode 100644 Migrations/20230812095148_Initial.Designer.cs create mode 100644 Migrations/20230812095148_Initial.cs (limited to 'Migrations') diff --git a/Migrations/20230811002826_Initial.Designer.cs b/Migrations/20230811002826_Initial.Designer.cs deleted file mode 100644 index 9db9176..0000000 --- a/Migrations/20230811002826_Initial.Designer.cs +++ /dev/null @@ -1,221 +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("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 deleted file mode 100644 index f3017e5..0000000 --- a/Migrations/20230811002826_Initial.cs +++ /dev/null @@ -1,180 +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) - }, - 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/20230812095148_Initial.Designer.cs b/Migrations/20230812095148_Initial.Designer.cs new file mode 100644 index 0000000..277e607 --- /dev/null +++ b/Migrations/20230812095148_Initial.Designer.cs @@ -0,0 +1,239 @@ +// +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("20230812095148_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); + + b.HasData( + new + { + ObjectId = -1, + Guid = new Guid("a03e1649-bd30-4db1-a81d-be05ba05f357"), + ObjectType = 0, + Name = "nsfw", + Source = 0 + }, + new + { + ObjectId = -2, + Guid = new Guid("3094fe00-8e41-4c08-8828-dea2ba878dd4"), + ObjectType = 0, + Name = "ingest", + Source = 0 + }); + }); + + 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/20230812095148_Initial.cs b/Migrations/20230812095148_Initial.cs new file mode 100644 index 0000000..40150bd --- /dev/null +++ b/Migrations/20230812095148_Initial.cs @@ -0,0 +1,200 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +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.InsertData( + table: "Objects", + columns: new[] { "ObjectId", "Guid", "ObjectType" }, + values: new object[,] + { + { -2, new Guid("3094fe00-8e41-4c08-8828-dea2ba878dd4"), 0 }, + { -1, new Guid("a03e1649-bd30-4db1-a81d-be05ba05f357"), 0 } + }); + + migrationBuilder.InsertData( + table: "TagDefinitions", + columns: new[] { "ObjectId", "DbTagDefinitionObjectId", "Name", "Namespace", "Source" }, + values: new object[,] + { + { -2, null, "ingest", null, 0 }, + { -1, null, "nsfw", null, 0 } + }); + + 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 36f6e72..7096799 100644 --- a/Migrations/HyperBooruDbContextModelSnapshot.cs +++ b/Migrations/HyperBooruDbContextModelSnapshot.cs @@ -138,6 +138,24 @@ namespace HyperBooru.Migrations b.HasIndex("DbTagDefinitionObjectId"); b.ToTable("TagDefinitions", (string)null); + + b.HasData( + new + { + ObjectId = -1, + Guid = new Guid("a03e1649-bd30-4db1-a81d-be05ba05f357"), + ObjectType = 0, + Name = "nsfw", + Source = 0 + }, + new + { + ObjectId = -2, + Guid = new Guid("3094fe00-8e41-4c08-8828-dea2ba878dd4"), + ObjectType = 0, + Name = "ingest", + Source = 0 + }); }); modelBuilder.Entity("HyperBooru.DbUploadedFile", b => -- cgit v1.3