From 8e94a12be4a56447e78d68c37def772bef8cade4 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Tue, 15 Aug 2023 15:49:14 +1000 Subject: Convert Razor pages to Blazor --- Migrations/20230812095148_Initial.Designer.cs | 239 ------------------------- Migrations/20230812095148_Initial.cs | 200 --------------------- Migrations/20230814013743_Initial.Designer.cs | 234 ++++++++++++++++++++++++ Migrations/20230814013743_Initial.cs | 199 ++++++++++++++++++++ Migrations/HBContextModelSnapshot.cs | 231 ++++++++++++++++++++++++ Migrations/HyperBooruDbContextModelSnapshot.cs | 236 ------------------------ 6 files changed, 664 insertions(+), 675 deletions(-) delete mode 100644 Migrations/20230812095148_Initial.Designer.cs delete mode 100644 Migrations/20230812095148_Initial.cs create mode 100644 Migrations/20230814013743_Initial.Designer.cs create mode 100644 Migrations/20230814013743_Initial.cs create mode 100644 Migrations/HBContextModelSnapshot.cs delete mode 100644 Migrations/HyperBooruDbContextModelSnapshot.cs (limited to 'Migrations') diff --git a/Migrations/20230812095148_Initial.Designer.cs b/Migrations/20230812095148_Initial.Designer.cs deleted file mode 100644 index 277e607..0000000 --- a/Migrations/20230812095148_Initial.Designer.cs +++ /dev/null @@ -1,239 +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("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 deleted file mode 100644 index 40150bd..0000000 --- a/Migrations/20230812095148_Initial.cs +++ /dev/null @@ -1,200 +0,0 @@ -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/20230814013743_Initial.Designer.cs b/Migrations/20230814013743_Initial.Designer.cs new file mode 100644 index 0000000..c221c85 --- /dev/null +++ b/Migrations/20230814013743_Initial.Designer.cs @@ -0,0 +1,234 @@ +// +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("20230814013743_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.HBObject", b => + { + b.Property("ObjectId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Guid") + .HasColumnType("TEXT"); + + b.HasKey("ObjectId"); + + b.HasIndex("Guid"); + + b.ToTable("Objects", (string)null); + + b.UseTptMappingStrategy(); + }); + + modelBuilder.Entity("HyperBooru.UploadedFile", 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.Media", b => + { + b.HasBaseType("HyperBooru.HBObject"); + + 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.Tag", b => + { + b.HasBaseType("HyperBooru.HBObject"); + + 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.TagDefinition", b => + { + b.HasBaseType("HyperBooru.HBObject"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Namespace") + .HasColumnType("TEXT"); + + b.Property("Source") + .HasColumnType("INTEGER"); + + b.Property("TagDefinitionObjectId") + .HasColumnType("INTEGER"); + + b.HasIndex("TagDefinitionObjectId"); + + b.ToTable("TagDefinitions", (string)null); + + b.HasData( + new + { + ObjectId = -1, + Guid = new Guid("cbd871cb-8790-4519-9f74-90d1e13a48a0"), + Name = "nsfw", + Source = 0 + }, + new + { + ObjectId = -2, + Guid = new Guid("716ac11f-135a-433c-84a7-7bdfddbec004"), + 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("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(); + + b.HasOne("HyperBooru.TagDefinition", null) + .WithMany("ImplicitTags") + .HasForeignKey("TagDefinitionObjectId"); + }); + + modelBuilder.Entity("HyperBooru.HBObject", b => + { + b.Navigation("Tags"); + }); + + modelBuilder.Entity("HyperBooru.Media", b => + { + b.Navigation("UploadedFiles"); + }); + + modelBuilder.Entity("HyperBooru.TagDefinition", b => + { + b.Navigation("ImplicitTags"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230814013743_Initial.cs b/Migrations/20230814013743_Initial.cs new file mode 100644 index 0000000..1390c18 --- /dev/null +++ b/Migrations/20230814013743_Initial.cs @@ -0,0 +1,199 @@ +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) + }, + 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), + TagDefinitionObjectId = 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_TagDefinitionObjectId", + column: x => x.TagDefinitionObjectId, + 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" }, + values: new object[,] + { + { -2, new Guid("716ac11f-135a-433c-84a7-7bdfddbec004") }, + { -1, new Guid("cbd871cb-8790-4519-9f74-90d1e13a48a0") } + }); + + migrationBuilder.InsertData( + table: "TagDefinitions", + columns: new[] { "ObjectId", "Name", "Namespace", "Source", "TagDefinitionObjectId" }, + values: new object[,] + { + { -2, "ingest", null, 0, null }, + { -1, "nsfw", null, 0, null } + }); + + migrationBuilder.CreateIndex( + name: "IX_Objects_Guid", + table: "Objects", + column: "Guid"); + + migrationBuilder.CreateIndex( + name: "IX_TagDefinitions_TagDefinitionObjectId", + table: "TagDefinitions", + column: "TagDefinitionObjectId"); + + 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/HBContextModelSnapshot.cs b/Migrations/HBContextModelSnapshot.cs new file mode 100644 index 0000000..9697e16 --- /dev/null +++ b/Migrations/HBContextModelSnapshot.cs @@ -0,0 +1,231 @@ +// +using System; +using HyperBooru; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace HyperBooru.Migrations +{ + [DbContext(typeof(HBContext))] + partial class HBContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(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("ObjectId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Guid") + .HasColumnType("TEXT"); + + b.HasKey("ObjectId"); + + b.HasIndex("Guid"); + + b.ToTable("Objects", (string)null); + + b.UseTptMappingStrategy(); + }); + + modelBuilder.Entity("HyperBooru.UploadedFile", 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.Media", b => + { + b.HasBaseType("HyperBooru.HBObject"); + + 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.Tag", b => + { + b.HasBaseType("HyperBooru.HBObject"); + + 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.TagDefinition", b => + { + b.HasBaseType("HyperBooru.HBObject"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Namespace") + .HasColumnType("TEXT"); + + b.Property("Source") + .HasColumnType("INTEGER"); + + b.Property("TagDefinitionObjectId") + .HasColumnType("INTEGER"); + + b.HasIndex("TagDefinitionObjectId"); + + b.ToTable("TagDefinitions", (string)null); + + b.HasData( + new + { + ObjectId = -1, + Guid = new Guid("cbd871cb-8790-4519-9f74-90d1e13a48a0"), + Name = "nsfw", + Source = 0 + }, + new + { + ObjectId = -2, + Guid = new Guid("716ac11f-135a-433c-84a7-7bdfddbec004"), + 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("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(); + + b.HasOne("HyperBooru.TagDefinition", null) + .WithMany("ImplicitTags") + .HasForeignKey("TagDefinitionObjectId"); + }); + + modelBuilder.Entity("HyperBooru.HBObject", b => + { + b.Navigation("Tags"); + }); + + modelBuilder.Entity("HyperBooru.Media", b => + { + b.Navigation("UploadedFiles"); + }); + + modelBuilder.Entity("HyperBooru.TagDefinition", b => + { + b.Navigation("ImplicitTags"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/HyperBooruDbContextModelSnapshot.cs b/Migrations/HyperBooruDbContextModelSnapshot.cs deleted file mode 100644 index 7096799..0000000 --- a/Migrations/HyperBooruDbContextModelSnapshot.cs +++ /dev/null @@ -1,236 +0,0 @@ -// -using System; -using HyperBooru; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace HyperBooru.Migrations -{ - [DbContext(typeof(HyperBooruDbContext))] - partial class HyperBooruDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(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 - } - } -} -- cgit v1.3