using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Iceshrimp.Backend.Core.Database.Tables; [Table("note_edit")] [Index(nameof(NoteId))] public class NoteEdit { [Key] [Column("id")] [StringLength(32)] public string Id { get; set; } = null!; /// /// The ID of note. /// [Column("noteId")] [StringLength(32)] public string NoteId { get; set; } = null!; [Column("text")] public string? Text { get; set; } [Column("cw")] [StringLength(512)] public string? Cw { get; set; } [Column("fileIds", TypeName = "character varying(32)[]")] public List FileIds { get; set; } = null!; /// /// The updated date of the Note. /// [Column("updatedAt")] public DateTime UpdatedAt { get; set; } [ForeignKey(nameof(NoteId))] [InverseProperty(nameof(Tables.Note.NoteEdits))] public virtual Note Note { get; set; } = null!; private class EntityTypeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { entity.Property(e => e.FileIds).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.NoteId).HasComment("The ID of note."); entity.Property(e => e.UpdatedAt).HasComment("The updated date of the Note."); entity.HasOne(d => d.Note) .WithMany(p => p.NoteEdits) .OnDelete(DeleteBehavior.Cascade); } } }