diff --git a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs index c6d24cda..2d2c0604 100644 --- a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs +++ b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs @@ -655,6 +655,10 @@ public class DatabaseContext(DbContextOptions options) entity.Property(e => e.UserHost).HasComment("[Denormalized]"); entity.Property(e => e.UserId).HasComment("The ID of author."); entity.Property(e => e.VisibleUserIds).HasDefaultValueSql("'{}'::character varying[]"); + entity.Property(e => e.ReplyUri) + .HasComment("The URI of the reply target, if it couldn't be resolved at time of ingestion."); + entity.Property(e => e.RenoteUri) + .HasComment("The URI of the renote target, if it couldn't be resolved at time of ingestion."); entity.HasOne(d => d.Channel) .WithMany(p => p.Notes) diff --git a/Iceshrimp.Backend/Core/Database/Migrations/20240429190728_AddNoteRenoteReplyUriColumns.cs b/Iceshrimp.Backend/Core/Database/Migrations/20240429190728_AddNoteRenoteReplyUriColumns.cs new file mode 100644 index 00000000..b71c791b --- /dev/null +++ b/Iceshrimp.Backend/Core/Database/Migrations/20240429190728_AddNoteRenoteReplyUriColumns.cs @@ -0,0 +1,63 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Infrastructure; + +#nullable disable + +namespace Iceshrimp.Backend.Core.Database.Migrations +{ + /// + [DbContext(typeof(DatabaseContext))] + [Migration("20240429190728_AddNoteRenoteReplyUriColumns")] + public partial class AddNoteRenoteReplyUriColumns : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "renoteUri", + table: "note", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "The URI of the renote target, if it couldn't be resolved at time of ingestion."); + + migrationBuilder.AddColumn( + name: "replyUri", + table: "note", + type: "character varying(512)", + maxLength: 512, + nullable: true, + comment: "The URI of the reply target, if it couldn't be resolved at time of ingestion."); + + migrationBuilder.CreateIndex( + name: "IX_note_renoteUri", + table: "note", + column: "renoteUri"); + + migrationBuilder.CreateIndex( + name: "IX_note_replyUri", + table: "note", + column: "replyUri"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_note_renoteUri", + table: "note"); + + migrationBuilder.DropIndex( + name: "IX_note_replyUri", + table: "note"); + + migrationBuilder.DropColumn( + name: "renoteUri", + table: "note"); + + migrationBuilder.DropColumn( + name: "replyUri", + table: "note"); + } + } +} diff --git a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs index 9f78ddbb..84d26347 100644 --- a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs +++ b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs @@ -2417,6 +2417,12 @@ namespace Iceshrimp.Backend.Core.Database.Migrations .HasColumnName("renoteId") .HasComment("The ID of renote target."); + b.Property("RenoteUri") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasColumnName("renoteUri") + .HasComment("The URI of the renote target, if it couldn't be resolved at time of ingestion."); + b.Property("RenoteUserHost") .HasMaxLength(512) .HasColumnType("character varying(512)") @@ -2441,6 +2447,12 @@ namespace Iceshrimp.Backend.Core.Database.Migrations .HasColumnName("replyId") .HasComment("The ID of reply target."); + b.Property("ReplyUri") + .HasMaxLength(512) + .HasColumnType("character varying(512)") + .HasColumnName("replyUri") + .HasComment("The URI of the reply target, if it couldn't be resolved at time of ingestion."); + b.Property("ReplyUserHost") .HasMaxLength(512) .HasColumnType("character varying(512)") @@ -2530,8 +2542,12 @@ namespace Iceshrimp.Backend.Core.Database.Migrations b.HasIndex("RenoteId"); + b.HasIndex("RenoteUri"); + b.HasIndex("ReplyId"); + b.HasIndex("ReplyUri"); + b.HasIndex("Tags"); b.HasIndex("ThreadId"); diff --git a/Iceshrimp.Backend/Core/Database/Tables/Note.cs b/Iceshrimp.Backend/Core/Database/Tables/Note.cs index fcc1dbb6..c893f008 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Note.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Note.cs @@ -29,6 +29,8 @@ namespace Iceshrimp.Backend.Core.Database.Tables; [Index(nameof(Url))] [Index(nameof(UserId), nameof(Id))] [Index(nameof(Visibility))] +[Index(nameof(ReplyUri))] +[Index(nameof(RenoteUri))] public class Note : IEntity { [PgName("note_visibility_enum")] @@ -59,6 +61,20 @@ public class Note : IEntity [Column("renoteId")] [StringLength(32)] public string? RenoteId { get; set; } + + /// + /// The URI of the reply target, if it couldn't be resolved at time of ingestion. + /// + [Column("replyUri")] + [StringLength(512)] + public string? ReplyUri { get; set; } + + /// + /// The URI of the renote target, if it couldn't be resolved at time of ingestion. + /// + [Column("renoteUri")] + [StringLength(512)] + public string? RenoteUri { get; set; } [Column("text")] public string? Text { get; set; }