using System.Diagnostics.CodeAnalysis; using Iceshrimp.Backend.Core.Database.Tables; using Microsoft.EntityFrameworkCore; using Npgsql; namespace Iceshrimp.Backend.Core.Database; [SuppressMessage("ReSharper", "StringLiteralTypo")] [SuppressMessage("ReSharper", "IdentifierTypo")] public class DatabaseContext : DbContext { private readonly IConfiguration? _config; public DatabaseContext() { } public DatabaseContext(DbContextOptions options, IConfiguration? config) : base(options) { _config = config; } public virtual DbSet AbuseUserReports { get; init; } = null!; public virtual DbSet AccessTokens { get; init; } = null!; public virtual DbSet Announcements { get; init; } = null!; public virtual DbSet AnnouncementReads { get; init; } = null!; public virtual DbSet Antennas { get; init; } = null!; public virtual DbSet Apps { get; init; } = null!; public virtual DbSet AttestationChallenges { get; init; } = null!; public virtual DbSet AuthSessions { get; init; } = null!; public virtual DbSet Blockings { get; init; } = null!; public virtual DbSet Channels { get; init; } = null!; public virtual DbSet ChannelFollowings { get; init; } = null!; public virtual DbSet ChannelNotePins { get; init; } = null!; public virtual DbSet Clips { get; init; } = null!; public virtual DbSet ClipNotes { get; init; } = null!; public virtual DbSet DriveFiles { get; init; } = null!; public virtual DbSet DriveFolders { get; init; } = null!; public virtual DbSet Emojis { get; init; } = null!; public virtual DbSet FollowRequests { get; init; } = null!; public virtual DbSet Followings { get; init; } = null!; public virtual DbSet GalleryLikes { get; init; } = null!; public virtual DbSet GalleryPosts { get; init; } = null!; public virtual DbSet Hashtags { get; init; } = null!; public virtual DbSet HtmlNoteCacheEntries { get; init; } = null!; public virtual DbSet HtmlUserCacheEntries { get; init; } = null!; public virtual DbSet Instances { get; init; } = null!; public virtual DbSet MessagingMessages { get; init; } = null!; public virtual DbSet Meta { get; init; } = null!; public virtual DbSet ModerationLogs { get; init; } = null!; public virtual DbSet Mutings { get; init; } = null!; public virtual DbSet Notes { get; init; } = null!; public virtual DbSet NoteEdits { get; init; } = null!; public virtual DbSet NoteFavorites { get; init; } = null!; public virtual DbSet NoteReactions { get; init; } = null!; public virtual DbSet NoteThreadMutings { get; init; } = null!; public virtual DbSet NoteUnreads { get; init; } = null!; public virtual DbSet NoteWatchings { get; init; } = null!; public virtual DbSet Notifications { get; init; } = null!; public virtual DbSet OauthApps { get; init; } = null!; public virtual DbSet OauthTokens { get; init; } = null!; public virtual DbSet Pages { get; init; } = null!; public virtual DbSet PageLikes { get; init; } = null!; public virtual DbSet PasswordResetRequests { get; init; } = null!; public virtual DbSet Polls { get; init; } = null!; public virtual DbSet PollVotes { get; init; } = null!; public virtual DbSet PromoNotes { get; init; } = null!; public virtual DbSet PromoReads { get; init; } = null!; public virtual DbSet RegistrationTickets { get; init; } = null!; public virtual DbSet RegistryItems { get; init; } = null!; public virtual DbSet Relays { get; init; } = null!; public virtual DbSet RenoteMutings { get; init; } = null!; public virtual DbSet Sessions { get; init; } = null!; public virtual DbSet Signins { get; init; } = null!; public virtual DbSet SwSubscriptions { get; init; } = null!; public virtual DbSet UsedUsernames { get; init; } = null!; public virtual DbSet Users { get; init; } = null!; public virtual DbSet UserGroups { get; init; } = null!; public virtual DbSet UserGroupInvitations { get; init; } = null!; public virtual DbSet UserGroupInvites { get; init; } = null!; public virtual DbSet UserGroupMembers { get; init; } = null!; public virtual DbSet UserKeypairs { get; init; } = null!; public virtual DbSet UserLists { get; init; } = null!; public virtual DbSet UserListMembers { get; init; } = null!; public virtual DbSet UserNotePins { get; init; } = null!; public virtual DbSet UserPendings { get; init; } = null!; public virtual DbSet UserProfiles { get; init; } = null!; public virtual DbSet UserPublickeys { get; init; } = null!; public virtual DbSet UserSecurityKeys { get; init; } = null!; public virtual DbSet Webhooks { get; init; } = null!; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var dataSourceBuilder = new NpgsqlDataSourceBuilder(); var config = _config?.GetSection("Database") ?? throw new Exception("Configuration is missing the [Database] section"); dataSourceBuilder.ConnectionStringBuilder.Host = config["Host"]; dataSourceBuilder.ConnectionStringBuilder.Username = config["Username"]; dataSourceBuilder.ConnectionStringBuilder.Password = config["Password"]; dataSourceBuilder.ConnectionStringBuilder.Database = config["Database"]; dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); // FIXME: WHY IS THIS ITS OWN ENUM dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); // FIXME: WHY IS THIS ITS OWN ENUM optionsBuilder.UseNpgsql(dataSourceBuilder.Build()); } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder .HasPostgresEnum() .HasPostgresEnum() .HasPostgresEnum() .HasPostgresEnum() .HasPostgresEnum() //TODO: merge with regular notevisibility enum .HasPostgresEnum() .HasPostgresEnum() .HasPostgresEnum() //TODO: merge with regular notification types enum .HasPostgresExtension("pg_trgm"); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the AbuseUserReport."); entity.Property(e => e.Forwarded).HasDefaultValue(false); entity.Property(e => e.ReporterHost).HasComment("[Denormalized]"); entity.Property(e => e.Resolved).HasDefaultValue(false); entity.Property(e => e.TargetUserHost).HasComment("[Denormalized]"); entity.HasOne(d => d.Assignee).WithMany(p => p.AbuseUserReportAssignees) .OnDelete(DeleteBehavior.SetNull); entity.HasOne(d => d.Reporter).WithMany(p => p.AbuseUserReportReporters); entity.HasOne(d => d.TargetUser).WithMany(p => p.AbuseUserReportTargetUsers); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the AccessToken."); entity.Property(e => e.Fetched).HasDefaultValue(false); entity.Property(e => e.Permission).HasDefaultValueSql("'{}'::character varying[]"); entity.HasOne(d => d.App).WithMany(p => p.AccessTokens) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.User).WithMany(p => p.AccessTokens); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the Announcement."); entity.Property(e => e.IsGoodNews).HasDefaultValue(false); entity.Property(e => e.ShowPopup).HasDefaultValue(false); entity.Property(e => e.UpdatedAt).HasComment("The updated date of the Announcement."); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the AnnouncementRead."); entity.HasOne(d => d.Announcement).WithMany(p => p.AnnouncementReads); entity.HasOne(d => d.User).WithMany(p => p.AnnouncementReads); }); modelBuilder.Entity(entity => { entity.Property(e => e.CaseSensitive).HasDefaultValue(false); entity.Property(e => e.CreatedAt).HasComment("The created date of the Antenna."); entity.Property(e => e.ExcludeKeywords).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.Instances).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.Keywords).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.Name).HasComment("The name of the Antenna."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.Property(e => e.Users).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.WithReplies).HasDefaultValue(false); entity.HasOne(d => d.UserGroupMember).WithMany(p => p.Antennas) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.User).WithMany(p => p.Antennas); entity.HasOne(d => d.UserList).WithMany(p => p.Antennas) .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity(entity => { entity.Property(e => e.CallbackUrl).HasComment("The callbackUrl of the App."); entity.Property(e => e.CreatedAt).HasComment("The created date of the App."); entity.Property(e => e.Description).HasComment("The description of the App."); entity.Property(e => e.Name).HasComment("The name of the App."); entity.Property(e => e.Permission).HasComment("The permission of the App."); entity.Property(e => e.Secret).HasComment("The secret key of the App."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.HasOne(d => d.User).WithMany(p => p.Apps) .OnDelete(DeleteBehavior.SetNull); }); modelBuilder.Entity(entity => { entity.Property(e => e.Challenge).HasComment("Hex-encoded sha256 hash of the challenge."); entity.Property(e => e.CreatedAt).HasComment("The date challenge was created for expiry purposes."); entity.Property(e => e.RegistrationChallenge) .HasDefaultValue(false) .HasComment("Indicates that the challenge is only for registration purposes if true to prevent the challenge for being used as authentication."); entity.HasOne(d => d.User).WithMany(p => p.AttestationChallenges); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the AuthSession."); entity.HasOne(d => d.App).WithMany(p => p.AuthSessions); entity.HasOne(d => d.User).WithMany(p => p.AuthSessions) .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity(entity => { entity.Property(e => e.BlockeeId).HasComment("The blockee user ID."); entity.Property(e => e.BlockerId).HasComment("The blocker user ID."); entity.Property(e => e.CreatedAt).HasComment("The created date of the Blocking."); entity.HasOne(d => d.Blockee).WithMany(p => p.BlockingBlockees); entity.HasOne(d => d.Blocker).WithMany(p => p.BlockingBlockers); }); modelBuilder.Entity(entity => { entity.Property(e => e.BannerId).HasComment("The ID of banner Channel."); entity.Property(e => e.CreatedAt).HasComment("The created date of the Channel."); entity.Property(e => e.Description).HasComment("The description of the Channel."); entity.Property(e => e.Name).HasComment("The name of the Channel."); entity.Property(e => e.NotesCount) .HasDefaultValue(0) .HasComment("The count of notes."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.Property(e => e.UsersCount) .HasDefaultValue(0) .HasComment("The count of users."); entity.HasOne(d => d.Banner).WithMany(p => p.Channels) .OnDelete(DeleteBehavior.SetNull); entity.HasOne(d => d.User).WithMany(p => p.Channels) .OnDelete(DeleteBehavior.SetNull); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the ChannelFollowing."); entity.Property(e => e.FolloweeId).HasComment("The followee channel ID."); entity.Property(e => e.FollowerId).HasComment("The follower user ID."); entity.HasOne(d => d.Followee).WithMany(p => p.ChannelFollowings); entity.HasOne(d => d.Follower).WithMany(p => p.ChannelFollowings); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the ChannelNotePin."); entity.HasOne(d => d.Channel).WithMany(p => p.ChannelNotePins); entity.HasOne(d => d.Note).WithMany(p => p.ChannelNotePins); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the Clip."); entity.Property(e => e.Description).HasComment("The description of the Clip."); entity.Property(e => e.IsPublic).HasDefaultValue(false); entity.Property(e => e.Name).HasComment("The name of the Clip."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.HasOne(d => d.User).WithMany(p => p.Clips); }); modelBuilder.Entity(entity => { entity.Property(e => e.ClipId).HasComment("The clip ID."); entity.Property(e => e.NoteId).HasComment("The note ID."); entity.HasOne(d => d.Clip).WithMany(p => p.ClipNotes); entity.HasOne(d => d.Note).WithMany(p => p.ClipNotes); }); modelBuilder.Entity(entity => { entity.Property(e => e.Blurhash).HasComment("The BlurHash string."); entity.Property(e => e.Comment).HasComment("The comment of the DriveFile."); entity.Property(e => e.CreatedAt).HasComment("The created date of the DriveFile."); entity.Property(e => e.FolderId) .HasComment("The parent folder ID. If null, it means the DriveFile is located in root."); entity.Property(e => e.IsLink) .HasDefaultValue(false) .HasComment("Whether the DriveFile is direct link to remote server."); entity.Property(e => e.IsSensitive) .HasDefaultValue(false) .HasComment("Whether the DriveFile is NSFW."); entity.Property(e => e.Md5).HasComment("The MD5 hash of the DriveFile."); entity.Property(e => e.Name).HasComment("The file name of the DriveFile."); entity.Property(e => e.Properties) .HasDefaultValueSql("'{}'::jsonb") .HasComment("The any properties of the DriveFile. For example, it includes image width/height."); entity.Property(e => e.RequestHeaders).HasDefaultValueSql("'{}'::jsonb"); entity.Property(e => e.Size).HasComment("The file size (bytes) of the DriveFile."); entity.Property(e => e.ThumbnailUrl).HasComment("The URL of the thumbnail of the DriveFile."); entity.Property(e => e.Type).HasComment("The content type (MIME) of the DriveFile."); entity.Property(e => e.Uri) .HasComment("The URI of the DriveFile. it will be null when the DriveFile is local."); entity.Property(e => e.Url).HasComment("The URL of the DriveFile."); entity.Property(e => e.UserHost).HasComment("The host of owner. It will be null if the user in local."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.Property(e => e.WebpublicUrl).HasComment("The URL of the webpublic of the DriveFile."); entity.HasOne(d => d.Folder).WithMany(p => p.DriveFiles) .OnDelete(DeleteBehavior.SetNull); entity.HasOne(d => d.User).WithMany(p => p.DriveFiles) .OnDelete(DeleteBehavior.SetNull); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the DriveFolder."); entity.Property(e => e.Name).HasComment("The name of the DriveFolder."); entity.Property(e => e.ParentId) .HasComment("The parent folder ID. If null, it means the DriveFolder is located in root."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.HasOne(d => d.Parent).WithMany(p => p.InverseParent) .OnDelete(DeleteBehavior.SetNull); entity.HasOne(d => d.User).WithMany(p => p.DriveFolders) .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity(entity => { entity.Property(e => e.Aliases).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.Height).HasComment("Image height"); entity.Property(e => e.PublicUrl).HasDefaultValueSql("''::character varying"); entity.Property(e => e.Width).HasComment("Image width"); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the FollowRequest."); entity.Property(e => e.FolloweeHost).HasComment("[Denormalized]"); entity.Property(e => e.FolloweeId).HasComment("The followee user ID."); entity.Property(e => e.FolloweeInbox).HasComment("[Denormalized]"); entity.Property(e => e.FolloweeSharedInbox).HasComment("[Denormalized]"); entity.Property(e => e.FollowerHost).HasComment("[Denormalized]"); entity.Property(e => e.FollowerId).HasComment("The follower user ID."); entity.Property(e => e.FollowerInbox).HasComment("[Denormalized]"); entity.Property(e => e.FollowerSharedInbox).HasComment("[Denormalized]"); entity.Property(e => e.RequestId).HasComment("id of Follow Activity."); entity.HasOne(d => d.Followee).WithMany(p => p.FollowRequestFollowees); entity.HasOne(d => d.Follower).WithMany(p => p.FollowRequestFollowers); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the Following."); entity.Property(e => e.FolloweeHost).HasComment("[Denormalized]"); entity.Property(e => e.FolloweeId).HasComment("The followee user ID."); entity.Property(e => e.FolloweeInbox).HasComment("[Denormalized]"); entity.Property(e => e.FolloweeSharedInbox).HasComment("[Denormalized]"); entity.Property(e => e.FollowerHost).HasComment("[Denormalized]"); entity.Property(e => e.FollowerId).HasComment("The follower user ID."); entity.Property(e => e.FollowerInbox).HasComment("[Denormalized]"); entity.Property(e => e.FollowerSharedInbox).HasComment("[Denormalized]"); entity.HasOne(d => d.Followee).WithMany(p => p.FollowingFollowees); entity.HasOne(d => d.Follower).WithMany(p => p.FollowingFollowers); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.Post).WithMany(p => p.GalleryLikes); entity.HasOne(d => d.User).WithMany(p => p.GalleryLikes); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the GalleryPost."); entity.Property(e => e.FileIds).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.IsSensitive) .HasDefaultValue(false) .HasComment("Whether the post is sensitive."); entity.Property(e => e.LikedCount).HasDefaultValue(0); entity.Property(e => e.Tags).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.UpdatedAt).HasComment("The updated date of the GalleryPost."); entity.Property(e => e.UserId).HasComment("The ID of author."); entity.HasOne(d => d.User).WithMany(p => p.GalleryPosts); }); modelBuilder.Entity(entity => { entity.Property(e => e.AttachedLocalUsersCount).HasDefaultValue(0); entity.Property(e => e.AttachedRemoteUsersCount).HasDefaultValue(0); entity.Property(e => e.AttachedUsersCount).HasDefaultValue(0); entity.Property(e => e.MentionedLocalUsersCount).HasDefaultValue(0); entity.Property(e => e.MentionedRemoteUsersCount).HasDefaultValue(0); entity.Property(e => e.MentionedUsersCount).HasDefaultValue(0); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.Note).WithOne(p => p.HtmlNoteCacheEntry); }); modelBuilder.Entity(entity => { entity.Property(e => e.Fields).HasDefaultValueSql("'[]'::jsonb"); entity.HasOne(d => d.User).WithOne(p => p.HtmlUserCacheEntry); }); modelBuilder.Entity(entity => { entity.Property(e => e.CaughtAt).HasComment("The caught date of the Instance."); entity.Property(e => e.FollowersCount).HasDefaultValue(0); entity.Property(e => e.FollowingCount).HasDefaultValue(0); entity.Property(e => e.Host).HasComment("The host of the Instance."); entity.Property(e => e.IsNotResponding).HasDefaultValue(false); entity.Property(e => e.IsSuspended).HasDefaultValue(false); entity.Property(e => e.NotesCount) .HasDefaultValue(0) .HasComment("The count of the notes of the Instance."); entity.Property(e => e.SoftwareName).HasComment("The software of the Instance."); entity.Property(e => e.UsersCount) .HasDefaultValue(0) .HasComment("The count of the users of the Instance."); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the MessagingMessage."); entity.Property(e => e.GroupId).HasComment("The recipient group ID."); entity.Property(e => e.IsRead).HasDefaultValue(false); entity.Property(e => e.Reads).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.RecipientId).HasComment("The recipient user ID."); entity.Property(e => e.UserId).HasComment("The sender user ID."); entity.HasOne(d => d.File).WithMany(p => p.MessagingMessages) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.Group).WithMany(p => p.MessagingMessages) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.Recipient).WithMany(p => p.MessagingMessageRecipients) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.User).WithMany(p => p.MessagingMessageUsers); }); modelBuilder.Entity(entity => { entity.Property(e => e.AllowedHosts).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.BlockedHosts).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.CacheRemoteFiles).HasDefaultValue(false); entity.Property(e => e.CustomMotd).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.CustomSplashIcons).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.DeeplIsPro).HasDefaultValue(false); entity.Property(e => e.DefaultReaction).HasDefaultValueSql("'⭐'::character varying"); entity.Property(e => e.DisableGlobalTimeline).HasDefaultValue(false); entity.Property(e => e.DisableLocalTimeline).HasDefaultValue(false); entity.Property(e => e.DisableRecommendedTimeline).HasDefaultValue(true); entity.Property(e => e.DisableRegistration).HasDefaultValue(false); entity.Property(e => e.EmailRequiredForSignup).HasDefaultValue(false); entity.Property(e => e.EnableActiveEmailValidation).HasDefaultValue(true); entity.Property(e => e.EnableDiscordIntegration).HasDefaultValue(false); entity.Property(e => e.EnableEmail).HasDefaultValue(false); entity.Property(e => e.EnableGithubIntegration).HasDefaultValue(false); entity.Property(e => e.EnableHcaptcha).HasDefaultValue(false); entity.Property(e => e.EnableIdenticonGeneration).HasDefaultValue(true); entity.Property(e => e.EnableIpLogging).HasDefaultValue(false); entity.Property(e => e.EnableRecaptcha).HasDefaultValue(false); entity.Property(e => e.EnableServerMachineStats).HasDefaultValue(false); entity.Property(e => e.ErrorImageUrl) .HasDefaultValueSql("'/static-assets/badges/error.png'::character varying"); entity.Property(e => e.ExperimentalFeatures).HasDefaultValueSql("'{}'::jsonb"); entity.Property(e => e.FeedbackUrl) .HasDefaultValueSql("'https://iceshrimp.dev/iceshrimp/iceshrimp/issues/new'::character varying"); entity.Property(e => e.HiddenTags).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.Langs).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.LocalDriveCapacityMb) .HasDefaultValue(1024) .HasComment("Drive capacity of a local user (MB)"); entity.Property(e => e.MascotImageUrl) .HasDefaultValueSql("'/static-assets/badges/info.png'::character varying"); entity.Property(e => e.ObjectStorageS3forcePathStyle).HasDefaultValue(true); entity.Property(e => e.ObjectStorageSetPublicRead).HasDefaultValue(false); entity.Property(e => e.ObjectStorageUseProxy).HasDefaultValue(true); entity.Property(e => e.ObjectStorageUseSsl).HasDefaultValue(true); entity.Property(e => e.PinnedPages) .HasDefaultValueSql("'{/featured,/channels,/explore,/pages,/about-iceshrimp}'::character varying[]"); entity.Property(e => e.PinnedUsers).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.PrivateMode).HasDefaultValue(false); entity.Property(e => e.RecommendedInstances).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.RemoteDriveCapacityMb) .HasDefaultValue(32) .HasComment("Drive capacity of a remote user (MB)"); entity.Property(e => e.RepositoryUrl) .HasDefaultValueSql("'https://iceshrimp.dev/iceshrimp/iceshrimp'::character varying"); entity.Property(e => e.SecureMode).HasDefaultValue(true); entity.Property(e => e.SilencedHosts).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.SmtpSecure).HasDefaultValue(false); entity.Property(e => e.UseObjectStorage).HasDefaultValue(false); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the ModerationLog."); entity.HasOne(d => d.User).WithMany(p => p.ModerationLogs); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the Muting."); entity.Property(e => e.MuteeId).HasComment("The mutee user ID."); entity.Property(e => e.MuterId).HasComment("The muter user ID."); entity.HasOne(d => d.Mutee).WithMany(p => p.MutingMutees); entity.HasOne(d => d.Muter).WithMany(p => p.MutingMuters); }); modelBuilder.Entity(entity => { entity.HasIndex(e => e.Mentions, "GIN_note_mentions").HasMethod("gin"); entity.HasIndex(e => e.Tags, "GIN_note_tags").HasMethod("gin"); entity.HasIndex(e => e.VisibleUserIds, "GIN_note_visibleUserIds").HasMethod("gin"); entity.HasIndex(e => e.Text, "GIN_TRGM_note_text") .HasMethod("gin") .HasOperators("gin_trgm_ops"); entity.Property(e => e.AttachedFileTypes).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.ChannelId).HasComment("The ID of source channel."); entity.Property(e => e.CreatedAt).HasComment("The created date of the Note."); entity.Property(e => e.Emojis).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.FileIds).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.HasPoll).HasDefaultValue(false); entity.Property(e => e.LocalOnly).HasDefaultValue(false); entity.Property(e => e.MentionedRemoteUsers).HasDefaultValueSql("'[]'::text"); entity.Property(e => e.Mentions).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.Reactions).HasDefaultValueSql("'{}'::jsonb"); entity.Property(e => e.RenoteCount).HasDefaultValue((short)0); entity.Property(e => e.RenoteId).HasComment("The ID of renote target."); entity.Property(e => e.RenoteUserHost).HasComment("[Denormalized]"); entity.Property(e => e.RenoteUserId).HasComment("[Denormalized]"); entity.Property(e => e.RepliesCount).HasDefaultValue((short)0); entity.Property(e => e.ReplyId).HasComment("The ID of reply target."); entity.Property(e => e.ReplyUserHost).HasComment("[Denormalized]"); entity.Property(e => e.ReplyUserId).HasComment("[Denormalized]"); entity.Property(e => e.Score).HasDefaultValue(0); entity.Property(e => e.Tags).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.UpdatedAt).HasComment("The updated date of the Note."); entity.Property(e => e.Uri).HasComment("The URI of a note. it will be null when the note is local."); entity.Property(e => e.Url) .HasComment("The human readable url of a note. it will be null when the note is local."); 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.HasOne(d => d.Channel).WithMany(p => p.Notes) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.Renote).WithMany(p => p.InverseRenote) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.Reply).WithMany(p => p.InverseReply) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.User).WithMany(p => p.Notes); }); modelBuilder.Entity(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); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the NoteFavorite."); entity.HasOne(d => d.Note).WithMany(p => p.NoteFavorites); entity.HasOne(d => d.User).WithMany(p => p.NoteFavorites); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the NoteReaction."); entity.HasOne(d => d.Note).WithMany(p => p.NoteReactions); entity.HasOne(d => d.User).WithMany(p => p.NoteReactions); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.User).WithMany(p => p.NoteThreadMutings); }); modelBuilder.Entity(entity => { entity.Property(e => e.NoteChannelId).HasComment("[Denormalized]"); entity.Property(e => e.NoteUserId).HasComment("[Denormalized]"); entity.HasOne(d => d.Note).WithMany(p => p.NoteUnreads); entity.HasOne(d => d.User).WithMany(p => p.NoteUnreads); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the NoteWatching."); entity.Property(e => e.NoteId).HasComment("The target Note ID."); entity.Property(e => e.NoteUserId).HasComment("[Denormalized]"); entity.Property(e => e.UserId).HasComment("The watcher ID."); entity.HasOne(d => d.Note).WithMany(p => p.NoteWatchings); entity.HasOne(d => d.User).WithMany(p => p.NoteWatchings); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the Notification."); entity.Property(e => e.IsRead) .HasDefaultValue(false) .HasComment("Whether the notification was read."); entity.Property(e => e.NotifieeId).HasComment("The ID of recipient user of the Notification."); entity.Property(e => e.NotifierId).HasComment("The ID of sender user of the Notification."); entity.Property(e => e.Type).HasComment("The type of the Notification."); entity.HasOne(d => d.AppAccessToken).WithMany(p => p.Notifications) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.FollowRequest).WithMany(p => p.Notifications) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.Note).WithMany(p => p.Notifications) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.Notifiee).WithMany(p => p.NotificationNotifiees); entity.HasOne(d => d.Notifier).WithMany(p => p.NotificationNotifiers) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.UserGroupInvitation).WithMany(p => p.Notifications) .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity(entity => { entity.Property(e => e.ClientId).HasComment("The client id of the OAuth application"); entity.Property(e => e.ClientSecret).HasComment("The client secret of the OAuth application"); entity.Property(e => e.CreatedAt).HasComment("The created date of the OAuth application"); entity.Property(e => e.Name).HasComment("The name of the OAuth application"); entity.Property(e => e.RedirectUris).HasComment("The redirect URIs of the OAuth application"); entity.Property(e => e.Scopes).HasComment("The scopes requested by the OAuth application"); entity.Property(e => e.Website).HasComment("The website of the OAuth application"); }); modelBuilder.Entity(entity => { entity.Property(e => e.Active).HasComment("Whether or not the token has been activated"); entity.Property(e => e.Code).HasComment("The auth code for the OAuth token"); entity.Property(e => e.CreatedAt).HasComment("The created date of the OAuth token"); entity.Property(e => e.RedirectUri).HasComment("The redirect URI of the OAuth token"); entity.Property(e => e.Scopes).HasComment("The scopes requested by the OAuth token"); entity.Property(e => e.Token).HasComment("The OAuth token"); entity.HasOne(d => d.App).WithMany(p => p.OauthTokens); entity.HasOne(d => d.User).WithMany(p => p.OauthTokens); }); modelBuilder.Entity(entity => { entity.Property(e => e.Content).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.CreatedAt).HasComment("The created date of the Page."); entity.Property(e => e.HideTitleWhenPinned).HasDefaultValue(false); entity.Property(e => e.LikedCount).HasDefaultValue(0); entity.Property(e => e.Script).HasDefaultValueSql("''::character varying"); entity.Property(e => e.UpdatedAt).HasComment("The updated date of the Page."); entity.Property(e => e.UserId).HasComment("The ID of author."); entity.Property(e => e.Variables).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.VisibleUserIds).HasDefaultValueSql("'{}'::character varying[]"); entity.HasOne(d => d.EyeCatchingImage).WithMany(p => p.Pages) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(d => d.User).WithMany(p => p.Pages); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.Page).WithMany(p => p.PageLikes); entity.HasOne(d => d.User).WithMany(p => p.PageLikes); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.User).WithMany(p => p.PasswordResetRequests); }); modelBuilder.Entity(entity => { entity.Property(e => e.Choices).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.UserHost).HasComment("[Denormalized]"); entity.Property(e => e.UserId).HasComment("[Denormalized]"); entity.Property(e => e.NoteVisibility).HasComment("[Denormalized]"); entity.HasOne(d => d.Note).WithOne(p => p.Poll); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the PollVote."); entity.HasOne(d => d.Note).WithMany(p => p.PollVotes); entity.HasOne(d => d.User).WithMany(p => p.PollVotes); }); modelBuilder.Entity(entity => { entity.Property(e => e.UserId).HasComment("[Denormalized]"); entity.HasOne(d => d.Note).WithOne(p => p.PromoNote); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the PromoRead."); entity.HasOne(d => d.Note).WithMany(p => p.PromoReads); entity.HasOne(d => d.User).WithMany(p => p.PromoReads); }); modelBuilder.Entity(entity => { }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the RegistryItem."); entity.Property(e => e.Key).HasComment("The key of the RegistryItem."); entity.Property(e => e.Scope).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.UpdatedAt).HasComment("The updated date of the RegistryItem."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.Property(e => e.Value) .HasDefaultValueSql("'{}'::jsonb") .HasComment("The value of the RegistryItem."); entity.HasOne(d => d.User).WithMany(p => p.RegistryItems); }); modelBuilder.Entity(entity => { }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the Muting."); entity.Property(e => e.MuteeId).HasComment("The mutee user ID."); entity.Property(e => e.MuterId).HasComment("The muter user ID."); entity.HasOne(d => d.Mutee).WithMany(p => p.RenoteMutingMutees); entity.HasOne(d => d.Muter).WithMany(p => p.RenoteMutingMuters); }); modelBuilder.Entity(entity => { entity.Property(e => e.Active) .HasComment("Whether or not the token has been activated (i.e. 2fa has been confirmed)"); entity.Property(e => e.CreatedAt).HasComment("The created date of the OAuth token"); entity.Property(e => e.Token).HasComment("The authorization token"); entity.HasOne(d => d.User).WithMany(p => p.Sessions); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the Signin."); entity.HasOne(d => d.User).WithMany(p => p.Signins); }); modelBuilder.Entity(entity => { entity.Property(e => e.SendReadMessage).HasDefaultValue(false); entity.HasOne(d => d.User).WithMany(p => p.SwSubscriptions); }); modelBuilder.Entity(entity => { }); modelBuilder.Entity(entity => { entity.Property(e => e.AlsoKnownAs).HasComment("URIs the user is known as too"); entity.Property(e => e.AvatarBlurhash).HasComment("The blurhash of the avatar DriveFile"); entity.Property(e => e.AvatarId).HasComment("The ID of avatar DriveFile."); entity.Property(e => e.AvatarUrl).HasComment("The URL of the avatar DriveFile"); entity.Property(e => e.BannerBlurhash).HasComment("The blurhash of the banner DriveFile"); entity.Property(e => e.BannerId).HasComment("The ID of banner DriveFile."); entity.Property(e => e.BannerUrl).HasComment("The URL of the banner DriveFile"); entity.Property(e => e.CreatedAt).HasComment("The created date of the User."); entity.Property(e => e.DriveCapacityOverrideMb).HasComment("Overrides user drive capacity limit"); entity.Property(e => e.Emojis).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.Featured) .HasComment("The featured URL of the User. It will be null if the origin of the user is local."); entity.Property(e => e.FollowersCount) .HasDefaultValue(0) .HasComment("The count of followers."); entity.Property(e => e.FollowersUri) .HasComment("The URI of the user Follower Collection. It will be null if the origin of the user is local."); entity.Property(e => e.FollowingCount) .HasDefaultValue(0) .HasComment("The count of following."); entity.Property(e => e.HideOnlineStatus).HasDefaultValue(false); entity.Property(e => e.Host) .HasComment("The host of the User. It will be null if the origin of the user is local."); entity.Property(e => e.Inbox) .HasComment("The inbox URL of the User. It will be null if the origin of the user is local."); entity.Property(e => e.IsAdmin) .HasDefaultValue(false) .HasComment("Whether the User is the admin."); entity.Property(e => e.IsBot) .HasDefaultValue(false) .HasComment("Whether the User is a bot."); entity.Property(e => e.IsCat) .HasDefaultValue(false) .HasComment("Whether the User is a cat."); entity.Property(e => e.IsDeleted) .HasDefaultValue(false) .HasComment("Whether the User is deleted."); entity.Property(e => e.IsExplorable) .HasDefaultValue(true) .HasComment("Whether the User is explorable."); entity.Property(e => e.IsLocked) .HasDefaultValue(false) .HasComment("Whether the User is locked."); entity.Property(e => e.IsModerator) .HasDefaultValue(false) .HasComment("Whether the User is a moderator."); entity.Property(e => e.IsSilenced) .HasDefaultValue(false) .HasComment("Whether the User is silenced."); entity.Property(e => e.IsSuspended) .HasDefaultValue(false) .HasComment("Whether the User is suspended."); entity.Property(e => e.MovedToUri).HasComment("The URI of the new account of the User"); entity.Property(e => e.Name).HasComment("The name of the User."); entity.Property(e => e.NotesCount) .HasDefaultValue(0) .HasComment("The count of notes."); entity.Property(e => e.SharedInbox) .HasComment("The sharedInbox URL of the User. It will be null if the origin of the user is local."); entity.Property(e => e.SpeakAsCat) .HasDefaultValue(true) .HasComment("Whether to speak as a cat if isCat."); entity.Property(e => e.Tags).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.Token) .IsFixedLength() .HasComment("The native access token of the User. It will be null if the origin of the user is local."); entity.Property(e => e.UpdatedAt).HasComment("The updated date of the User."); entity.Property(e => e.Uri) .HasComment("The URI of the User. It will be null if the origin of the user is local."); entity.Property(e => e.Username).HasComment("The username of the User."); entity.Property(e => e.UsernameLower).HasComment("The username (lowercased) of the User."); entity.HasOne(d => d.Avatar).WithOne(p => p.UserAvatar) .OnDelete(DeleteBehavior.SetNull); entity.HasOne(d => d.Banner).WithOne(p => p.UserBanner) .OnDelete(DeleteBehavior.SetNull); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the UserGroup."); entity.Property(e => e.IsPrivate).HasDefaultValue(false); entity.Property(e => e.UserId).HasComment("The ID of owner."); entity.HasOne(d => d.User).WithMany(p => p.UserGroups); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the UserGroupInvitation."); entity.Property(e => e.UserGroupId).HasComment("The group ID."); entity.Property(e => e.UserId).HasComment("The user ID."); entity.HasOne(d => d.UserGroup).WithMany(p => p.UserGroupInvitations); entity.HasOne(d => d.User).WithMany(p => p.UserGroupInvitations); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.UserGroup).WithMany(p => p.UserGroupInvites); entity.HasOne(d => d.User).WithMany(p => p.UserGroupInvites); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the UserGroupMember."); entity.Property(e => e.UserGroupId).HasComment("The group ID."); entity.Property(e => e.UserId).HasComment("The user ID."); entity.HasOne(d => d.UserGroup).WithMany(p => p.UserGroupMembers); entity.HasOne(d => d.User).WithMany(p => p.UserGroupMembers); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.User).WithOne(p => p.UserKeypair); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the UserList."); entity.Property(e => e.HideFromHomeTl) .HasDefaultValue(false) .HasComment("Whether posts from list members should be hidden from the home timeline."); entity.Property(e => e.Name).HasComment("The name of the UserList."); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.HasOne(d => d.User).WithMany(p => p.UserLists); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the UserListMember."); entity.Property(e => e.UserId).HasComment("The user ID."); entity.Property(e => e.UserListId).HasComment("The list ID."); entity.HasOne(d => d.User).WithMany(p => p.UserListMembers); entity.HasOne(d => d.UserList).WithMany(p => p.UserListMembers); }); modelBuilder.Entity(entity => { entity.Property(e => e.CreatedAt).HasComment("The created date of the UserNotePins."); entity.HasOne(d => d.Note).WithMany(p => p.UserNotePins); entity.HasOne(d => d.User).WithMany(p => p.UserNotePins); }); modelBuilder.Entity(entity => { }); modelBuilder.Entity(entity => { entity.Property(e => e.AlwaysMarkNsfw).HasDefaultValue(false); entity.Property(e => e.AutoAcceptFollowed).HasDefaultValue(false); entity.Property(e => e.Birthday) .IsFixedLength() .HasComment("The birthday (YYYY-MM-DD) of the User."); entity.Property(e => e.CarefulBot).HasDefaultValue(false); entity.Property(e => e.ClientData) .HasDefaultValueSql("'{}'::jsonb") .HasComment("The client-specific data of the User."); entity.Property(e => e.Description).HasComment("The description (bio) of the User."); entity.Property(e => e.Email).HasComment("The email address of the User."); entity.Property(e => e.EmailNotificationTypes) .HasDefaultValueSql("'[\"follow\", \"receiveFollowRequest\", \"groupInvited\"]'::jsonb"); entity.Property(e => e.EmailVerified).HasDefaultValue(false); entity.Property(e => e.EnableWordMute).HasDefaultValue(false); entity.Property(e => e.Fields).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.InjectFeaturedNote).HasDefaultValue(true); entity.Property(e => e.Integrations).HasDefaultValueSql("'{}'::jsonb"); entity.Property(e => e.Location).HasComment("The location of the User."); entity.Property(e => e.Mentions).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.ModerationNote).HasDefaultValueSql("''::character varying"); entity.Property(e => e.MutedInstances) .HasDefaultValueSql("'[]'::jsonb") .HasComment("List of instances muted by the user."); entity.Property(e => e.MutedWords).HasDefaultValueSql("'[]'::jsonb"); entity.Property(e => e.NoCrawle) .HasDefaultValue(false) .HasComment("Whether reject index by crawler."); entity.Property(e => e.Password) .HasComment("The password hash of the User. It will be null if the origin of the user is local."); entity.Property(e => e.PreventAiLearning).HasDefaultValue(true); entity.Property(e => e.PublicReactions).HasDefaultValue(false); entity.Property(e => e.ReceiveAnnouncementEmail).HasDefaultValue(true); entity.Property(e => e.Room) .HasDefaultValueSql("'{}'::jsonb") .HasComment("The room data of the User."); entity.Property(e => e.SecurityKeysAvailable).HasDefaultValue(false); entity.Property(e => e.TwoFactorEnabled).HasDefaultValue(false); entity.Property(e => e.Url).HasComment("Remote URL of the user."); entity.Property(e => e.UsePasswordLessLogin).HasDefaultValue(false); entity.Property(e => e.UserHost).HasComment("[Denormalized]"); entity.Property(e => e.MutingNotificationTypes) .HasDefaultValueSql("'{}'::public.user_profile_mutingnotificationtypes_enum[]"); entity.Property(e => e.FFVisibility) .HasDefaultValue(UserProfile.UserProfileFFVisibility.Public); entity.HasOne(d => d.PinnedPage).WithOne(p => p.UserProfile) .OnDelete(DeleteBehavior.SetNull); entity.HasOne(d => d.User).WithOne(p => p.UserProfile); }); modelBuilder.Entity(entity => { entity.HasOne(d => d.User).WithOne(p => p.UserPublickey); }); modelBuilder.Entity(entity => { entity.Property(e => e.Id).HasComment("Variable-length id given to navigator.credentials.get()"); entity.Property(e => e.LastUsed) .HasComment("The date of the last time the UserSecurityKey was successfully validated."); entity.Property(e => e.Name).HasComment("User-defined name for this key"); entity.Property(e => e.PublicKey) .HasComment("Variable-length public key used to verify attestations (hex-encoded)."); entity.HasOne(d => d.User).WithMany(p => p.UserSecurityKeys); }); modelBuilder.Entity(entity => { entity.Property(e => e.Active).HasDefaultValue(true); entity.Property(e => e.CreatedAt).HasComment("The created date of the Antenna."); entity.Property(e => e.Name).HasComment("The name of the Antenna."); entity.Property(e => e.On).HasDefaultValueSql("'{}'::character varying[]"); entity.Property(e => e.UserId).HasComment("The owner ID."); entity.HasOne(d => d.User).WithMany(p => p.Webhooks); }); } }