diff options
Diffstat (limited to 'Migrations')
| -rw-r--r-- | Migrations/20230811002826_Initial.Designer.cs (renamed from Migrations/20230809044429_Initial.Designer.cs) | 41 | ||||
| -rw-r--r-- | Migrations/20230811002826_Initial.cs (renamed from Migrations/20230809044429_Initial.cs) | 126 | ||||
| -rw-r--r-- | Migrations/HyperBooruDbContextModelSnapshot.cs | 39 |
3 files changed, 149 insertions, 57 deletions
diff --git a/Migrations/20230809044429_Initial.Designer.cs b/Migrations/20230811002826_Initial.Designer.cs index 78a0ca3..9db9176 100644 --- a/Migrations/20230809044429_Initial.Designer.cs +++ b/Migrations/20230811002826_Initial.Designer.cs @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace HyperBooru.Migrations { [DbContext(typeof(HyperBooruDbContext))] - [Migration("20230809044429_Initial")] + [Migration("20230811002826_Initial")] partial class Initial { /// <inheritdoc /> @@ -30,10 +30,6 @@ namespace HyperBooru.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property<string>("Discriminator") - .IsRequired() - .HasColumnType("TEXT"); - b.Property<Guid>("Guid") .HasColumnType("TEXT"); @@ -44,11 +40,9 @@ namespace HyperBooru.Migrations b.HasIndex("Guid"); - b.ToTable("Objects"); - - b.HasDiscriminator<string>("Discriminator").HasValue("DbObject"); + b.ToTable("Objects", (string)null); - b.UseTphMappingStrategy(); + b.UseTptMappingStrategy(); }); modelBuilder.Entity("HyperBooru.DbUploadedFile", b => @@ -83,7 +77,7 @@ namespace HyperBooru.Migrations b.HasIndex("MediaObjectId"); - b.ToTable("UploadedFiles"); + b.ToTable("UploadedFiles", (string)null); }); modelBuilder.Entity("HyperBooru.DbMedia", b => @@ -104,7 +98,7 @@ namespace HyperBooru.Migrations b.Property<string>("ShortDescription") .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("DbMedia"); + b.ToTable("Media", (string)null); }); modelBuilder.Entity("HyperBooru.DbTag", b => @@ -124,7 +118,7 @@ namespace HyperBooru.Migrations b.HasIndex("TargetObjectId"); - b.HasDiscriminator().HasValue("DbTag"); + b.ToTable("Tags", (string)null); }); modelBuilder.Entity("HyperBooru.DbTagDefinition", b => @@ -146,7 +140,7 @@ namespace HyperBooru.Migrations b.HasIndex("DbTagDefinitionObjectId"); - b.HasDiscriminator().HasValue("DbTagDefinition"); + b.ToTable("TagDefinitions", (string)null); }); modelBuilder.Entity("HyperBooru.DbUploadedFile", b => @@ -160,8 +154,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") @@ -184,6 +193,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 => diff --git a/Migrations/20230809044429_Initial.cs b/Migrations/20230811002826_Initial.cs index 0126c13..f3017e5 100644 --- a/Migrations/20230809044429_Initial.cs +++ b/Migrations/20230811002826_Initial.cs @@ -18,40 +18,60 @@ namespace HyperBooru.Migrations ObjectId = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Guid = table.Column<Guid>(type: "TEXT", nullable: false), - ObjectType = table.Column<int>(type: "INTEGER", nullable: false), - Discriminator = table.Column<string>(type: "TEXT", nullable: false), - Checksum = table.Column<string>(type: "TEXT", nullable: true), - MimeType = table.Column<string>(type: "TEXT", nullable: true), - ShortDescription = table.Column<string>(type: "TEXT", nullable: true), - LongDescription = table.Column<string>(type: "TEXT", nullable: true), - TagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: true), - CreateTime = table.Column<DateTime>(type: "TEXT", nullable: true), - TargetObjectId = table.Column<int>(type: "INTEGER", nullable: true), - Source = table.Column<int>(type: "INTEGER", nullable: true), - Namespace = table.Column<string>(type: "TEXT", nullable: true), - Name = table.Column<string>(type: "TEXT", nullable: true), - DbTagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: true) + ObjectType = table.Column<int>(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Objects", x => x.ObjectId); + }); + + migrationBuilder.CreateTable( + name: "Media", + columns: table => new + { + ObjectId = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Checksum = table.Column<string>(type: "TEXT", nullable: false), + MimeType = table.Column<string>(type: "TEXT", nullable: false), + ShortDescription = table.Column<string>(type: "TEXT", nullable: true), + LongDescription = table.Column<string>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Media", 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, + 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<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Source = table.Column<int>(type: "INTEGER", nullable: false), + Namespace = table.Column<string>(type: "TEXT", nullable: true), + Name = table.Column<string>(type: "TEXT", nullable: false), + DbTagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TagDefinitions", x => x.ObjectId); table.ForeignKey( - name: "FK_Objects_Objects_TargetObjectId", - column: x => x.TargetObjectId, + 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( @@ -72,17 +92,45 @@ namespace HyperBooru.Migrations { table.PrimaryKey("PK_UploadedFiles", x => x.UploadedFileId); table.ForeignKey( - name: "FK_UploadedFiles_Objects_MediaObjectId", + name: "FK_UploadedFiles_Media_MediaObjectId", column: x => x.MediaObjectId, - principalTable: "Objects", + principalTable: "Media", principalColumn: "ObjectId", onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateIndex( - name: "IX_Objects_DbTagDefinitionObjectId", - table: "Objects", - column: "DbTagDefinitionObjectId"); + migrationBuilder.CreateTable( + name: "Tags", + columns: table => new + { + ObjectId = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + TagDefinitionObjectId = table.Column<int>(type: "INTEGER", nullable: false), + CreateTime = table.Column<DateTime>(type: "TEXT", nullable: false), + TargetObjectId = table.Column<int>(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", @@ -90,13 +138,18 @@ namespace HyperBooru.Migrations column: "Guid"); migrationBuilder.CreateIndex( - name: "IX_Objects_TagDefinitionObjectId", - table: "Objects", + name: "IX_TagDefinitions_DbTagDefinitionObjectId", + table: "TagDefinitions", + column: "DbTagDefinitionObjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Tags_TagDefinitionObjectId", + table: "Tags", column: "TagDefinitionObjectId"); migrationBuilder.CreateIndex( - name: "IX_Objects_TargetObjectId", - table: "Objects", + name: "IX_Tags_TargetObjectId", + table: "Tags", column: "TargetObjectId"); migrationBuilder.CreateIndex( @@ -109,9 +162,18 @@ namespace HyperBooru.Migrations 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<string>("Discriminator") - .IsRequired() - .HasColumnType("TEXT"); - b.Property<Guid>("Guid") .HasColumnType("TEXT"); @@ -41,11 +37,9 @@ namespace HyperBooru.Migrations b.HasIndex("Guid"); - b.ToTable("Objects"); - - b.HasDiscriminator<string>("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<string>("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 => |
