diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240928133953_Media11.Designer.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240928133953_Media11.Designer.cs
new file mode 100644
index 00000000..76f3d428
--- /dev/null
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240928133953_Media11.Designer.cs
@@ -0,0 +1,900 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using OneShelf.Videos.Database;
+
+#nullable disable
+
+namespace OneShelf.Videos.Database.Migrations.VideosDatabaseMigrations
+{
+ [DbContext(typeof(VideosDatabase))]
+ [Migration("20240928133953_Media11")]
+ partial class Media11
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "8.0.8")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Album", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Albums");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.AlbumConstraint", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("After")
+ .HasColumnType("datetime2");
+
+ b.Property("AlbumId")
+ .HasColumnType("int");
+
+ b.Property("Before")
+ .HasColumnType("datetime2");
+
+ b.Property("Include")
+ .HasColumnType("bit");
+
+ b.Property("IsSquare")
+ .HasColumnType("bit");
+
+ b.Property("StaticMessageSelectedType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("StaticTopicId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AlbumId");
+
+ b.ToTable("AlbumConstraints");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.InventoryItem", b =>
+ {
+ b.Property("DatabaseInventoryItemId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DatabaseInventoryItemId"));
+
+ b.Property("BaseUrl")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ContributorInfoDisplayName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ContributorInfoProfilePictureBaseUrl")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Id")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("IsPhoto")
+ .HasColumnType("bit");
+
+ b.Property("IsVideo")
+ .HasColumnType("bit");
+
+ b.Property("MediaMetadataCreationTime")
+ .HasColumnType("datetime2");
+
+ b.Property("MediaMetadataHeight")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaMetadataPhotoApertureFNumber")
+ .HasColumnType("real");
+
+ b.Property("MediaMetadataPhotoCameraMake")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaMetadataPhotoCameraModel")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaMetadataPhotoExposureTime")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaMetadataPhotoFocalLength")
+ .HasColumnType("real");
+
+ b.Property("MediaMetadataPhotoIsoEquivalent")
+ .HasColumnType("int");
+
+ b.Property("MediaMetadataVideoCameraMake")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaMetadataVideoCameraModel")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaMetadataVideoFps")
+ .HasColumnType("float");
+
+ b.Property("MediaMetadataVideoStatus")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaMetadataWidth")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MimeType")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProductUrl")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SyncDate")
+ .HasColumnType("datetime2");
+
+ b.HasKey("DatabaseInventoryItemId");
+
+ b.ToTable("InventoryItems");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveChat", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("bigint");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("LiveChats");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveDownloadedItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("LiveMediaMediaId")
+ .HasColumnType("bigint");
+
+ b.Property("ThumbnailFileName")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FileName")
+ .IsUnique();
+
+ b.HasIndex("LiveMediaMediaId")
+ .IsUnique();
+
+ b.ToTable("LiveDownloadedItems");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveMedia", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("int");
+
+ b.Property("LiveTopicLiveChatId")
+ .HasColumnType("bigint");
+
+ b.Property("DocumentAttributeTypes")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DocumentAttributes")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Duration")
+ .HasColumnType("float");
+
+ b.Property("FileName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Flags")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Height")
+ .HasColumnType("int");
+
+ b.Property("IsForwarded")
+ .HasColumnType("bit");
+
+ b.Property("LiveTopicId")
+ .HasColumnType("int");
+
+ b.Property("MediaDate")
+ .HasColumnType("datetime2");
+
+ b.Property("MediaFlags")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaId")
+ .HasColumnType("bigint");
+
+ b.Property("MediaType")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MessageDate")
+ .HasColumnType("datetime2");
+
+ b.Property("MimeType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SelectedType")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("nvarchar(max)")
+ .HasComputedColumnSql("\r\ncase \r\nwhen type = 'Photo' then 'Photo' \r\nwhen MimeType like 'video/%' then 'Video' \r\nwhen mimetype = 'image/webp' then null \r\nwhen mimetype = 'application/x-tgsticker' then null\r\nwhen MimeType like 'image/%' then 'Photo' \r\nelse null\r\nend\r\n");
+
+ b.Property("Size")
+ .HasColumnType("bigint");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("VideoFlags")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Width")
+ .HasColumnType("int");
+
+ b.HasKey("Id", "LiveTopicLiveChatId");
+
+ b.HasIndex("LiveTopicId", "LiveTopicLiveChatId");
+
+ b.ToTable("LiveMediae");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveTopic", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("int");
+
+ b.Property("LiveChatId")
+ .HasColumnType("bigint");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id", "LiveChatId");
+
+ b.HasIndex("LiveChatId");
+
+ b.ToTable("LiveTopics");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Media", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("LiveChatId")
+ .HasColumnType("bigint");
+
+ b.Property("LiveMediaId")
+ .HasColumnType("int");
+
+ b.Property("StaticChatId")
+ .HasColumnType("bigint");
+
+ b.Property("StaticMessageId")
+ .HasColumnType("int");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LiveChatId");
+
+ b.HasIndex("LiveMediaId", "LiveChatId")
+ .IsUnique()
+ .HasFilter("[LiveMediaId] IS NOT NULL AND [LiveChatId] IS NOT NULL");
+
+ b.HasIndex("StaticChatId", "StaticMessageId")
+ .IsUnique()
+ .HasFilter("[StaticChatId] IS NOT NULL AND [StaticMessageId] IS NOT NULL");
+
+ b.ToTable("Mediae");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChat", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("bigint");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("StaticChatFolderId")
+ .HasColumnType("int");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("StaticChatFolderId")
+ .IsUnique();
+
+ b.ToTable("StaticChats");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChatFolder", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Root")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("StaticChatFolders");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticMessage", b =>
+ {
+ b.Property("StaticChatId")
+ .HasColumnType("bigint");
+
+ b.Property("Id")
+ .HasColumnType("int");
+
+ b.Property("Action")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Actor")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ActorId")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Boosts")
+ .HasColumnType("int");
+
+ b.Property("ContactInformation")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Date")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUnixtime")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Duration")
+ .HasColumnType("int");
+
+ b.Property("DurationSeconds")
+ .HasColumnType("int");
+
+ b.Property("Edited")
+ .HasColumnType("datetime2");
+
+ b.Property("EditedUnixtime")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("File")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("FileName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ForwardedFrom")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("From")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("FromId")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Height")
+ .HasColumnType("int");
+
+ b.Property("InlineBotButtons")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Inviter")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("LiveLocationPeriodSeconds")
+ .HasColumnType("int");
+
+ b.Property("LocationInformation")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Members")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MessageId")
+ .HasColumnType("int");
+
+ b.Property("MimeType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("NewIconEmojiId")
+ .HasColumnType("bigint");
+
+ b.Property("NewTitle")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Performer")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Photo")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Poll")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ReplyToMessageId")
+ .HasColumnType("int");
+
+ b.Property("ReplyToPeerId")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SavedFrom")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ScheduleDate")
+ .HasColumnType("int");
+
+ b.Property("SelectedType")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("nvarchar(max)")
+ .HasComputedColumnSql("case when photo is not null then 'photo' when mimetype like 'video/%' and isnull(mediatype, 'null') in ('video_file', 'null') then 'video' else null end");
+
+ b.Property("StaticTopicRootMessageIdOr0")
+ .HasColumnType("int");
+
+ b.Property("StickerEmoji")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Text")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("TextEntities")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Thumbnail")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Title")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ViaBot")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Width")
+ .HasColumnType("int");
+
+ b.HasKey("StaticChatId", "Id");
+
+ b.HasIndex("StaticChatId", "StaticTopicRootMessageIdOr0");
+
+ b.ToTable("StaticMessages");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticTopic", b =>
+ {
+ b.Property("StaticChatId")
+ .HasColumnType("bigint");
+
+ b.Property("RootMessageIdOr0")
+ .HasColumnType("int");
+
+ b.Property("Id")
+ .HasColumnType("int");
+
+ b.Property("OriginalTitle")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("StaticChatId", "RootMessageIdOr0");
+
+ b.ToTable("StaticTopics");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Topic", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("LiveChatId")
+ .HasColumnType("bigint");
+
+ b.Property("LiveTopicId")
+ .HasColumnType("int");
+
+ b.Property("StaticChatId")
+ .HasColumnType("bigint");
+
+ b.Property("StaticTopicRootMessageIdOr0")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LiveChatId");
+
+ b.HasIndex("LiveTopicId", "LiveChatId")
+ .IsUnique()
+ .HasFilter("[LiveTopicId] IS NOT NULL AND [LiveChatId] IS NOT NULL");
+
+ b.HasIndex("StaticChatId", "StaticTopicRootMessageIdOr0")
+ .IsUnique()
+ .HasFilter("[StaticChatId] IS NOT NULL AND [StaticTopicRootMessageIdOr0] IS NOT NULL");
+
+ b.ToTable("Topics");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.UploadedAlbum", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("AlbumId")
+ .HasColumnType("int");
+
+ b.Property("GoogleAlbumId")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AlbumId")
+ .IsUnique();
+
+ b.ToTable("UploadedAlbums");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.UploadedItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("FileNameTimestamp")
+ .HasColumnType("datetime2");
+
+ b.Property("Json")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaId")
+ .HasColumnType("int");
+
+ b.Property("MediaItemId")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaItemIsPhoto")
+ .HasColumnType("bit");
+
+ b.Property("MediaItemIsVideo")
+ .HasColumnType("bit");
+
+ b.Property("MediaItemMetadataCreationTime")
+ .HasColumnType("datetime2");
+
+ b.Property("MediaItemMimeType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("MediaItemSyncDate")
+ .HasColumnType("datetime2");
+
+ b.Property("Status")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("StatusCode")
+ .HasColumnType("int");
+
+ b.Property("StatusMessage")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("TelegramPublishedOn")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.HasIndex("MediaId")
+ .IsUnique();
+
+ b.ToTable("UploadedItems");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.AlbumConstraint", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Album", "Album")
+ .WithMany("Constraints")
+ .HasForeignKey("AlbumId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Album");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveMedia", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveTopic", "LiveTopic")
+ .WithMany("LiveMediae")
+ .HasForeignKey("LiveTopicId", "LiveTopicLiveChatId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("LiveTopic");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveTopic", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveChat", "LiveChat")
+ .WithMany("LiveTopics")
+ .HasForeignKey("LiveChatId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("LiveChat");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Media", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveChat", "LiveChat")
+ .WithMany("Mediae")
+ .HasForeignKey("LiveChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticChat", "StaticChat")
+ .WithMany("Mediae")
+ .HasForeignKey("StaticChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveMedia", "LiveMedia")
+ .WithOne("Media")
+ .HasForeignKey("OneShelf.Videos.Database.Models.Media", "LiveMediaId", "LiveChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticMessage", "StaticMessage")
+ .WithOne("Media")
+ .HasForeignKey("OneShelf.Videos.Database.Models.Media", "StaticChatId", "StaticMessageId");
+
+ b.Navigation("LiveChat");
+
+ b.Navigation("LiveMedia");
+
+ b.Navigation("StaticChat");
+
+ b.Navigation("StaticMessage");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChat", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticChatFolder", "StaticChatFolder")
+ .WithOne("StaticChat")
+ .HasForeignKey("OneShelf.Videos.Database.Models.Static.StaticChat", "StaticChatFolderId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("StaticChatFolder");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticMessage", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticChat", "StaticChat")
+ .WithMany("Messages")
+ .HasForeignKey("StaticChatId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticTopic", "StaticTopic")
+ .WithMany("StaticMessages")
+ .HasForeignKey("StaticChatId", "StaticTopicRootMessageIdOr0");
+
+ b.Navigation("StaticChat");
+
+ b.Navigation("StaticTopic");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticTopic", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticChat", "StaticChat")
+ .WithMany()
+ .HasForeignKey("StaticChatId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("StaticChat");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Topic", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveChat", "LiveChat")
+ .WithMany("Topics")
+ .HasForeignKey("LiveChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticChat", "StaticChat")
+ .WithMany("Topics")
+ .HasForeignKey("StaticChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveTopic", "LiveTopic")
+ .WithOne("Topic")
+ .HasForeignKey("OneShelf.Videos.Database.Models.Topic", "LiveTopicId", "LiveChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticTopic", "StaticTopic")
+ .WithOne("Topic")
+ .HasForeignKey("OneShelf.Videos.Database.Models.Topic", "StaticChatId", "StaticTopicRootMessageIdOr0");
+
+ b.Navigation("LiveChat");
+
+ b.Navigation("LiveTopic");
+
+ b.Navigation("StaticChat");
+
+ b.Navigation("StaticTopic");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.UploadedAlbum", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Album", "Album")
+ .WithOne("UploadedAlbum")
+ .HasForeignKey("OneShelf.Videos.Database.Models.UploadedAlbum", "AlbumId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Album");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.UploadedItem", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Media", "Media")
+ .WithOne("UploadedItem")
+ .HasForeignKey("OneShelf.Videos.Database.Models.UploadedItem", "MediaId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Media");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Album", b =>
+ {
+ b.Navigation("Constraints");
+
+ b.Navigation("UploadedAlbum");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveChat", b =>
+ {
+ b.Navigation("LiveTopics");
+
+ b.Navigation("Mediae");
+
+ b.Navigation("Topics");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveMedia", b =>
+ {
+ b.Navigation("Media");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveTopic", b =>
+ {
+ b.Navigation("LiveMediae");
+
+ b.Navigation("Topic");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Media", b =>
+ {
+ b.Navigation("UploadedItem");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChat", b =>
+ {
+ b.Navigation("Mediae");
+
+ b.Navigation("Messages");
+
+ b.Navigation("Topics");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChatFolder", b =>
+ {
+ b.Navigation("StaticChat");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticMessage", b =>
+ {
+ b.Navigation("Media");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticTopic", b =>
+ {
+ b.Navigation("StaticMessages");
+
+ b.Navigation("Topic");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240928133953_Media11.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240928133953_Media11.cs
new file mode 100644
index 00000000..a2b74dca
--- /dev/null
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240928133953_Media11.cs
@@ -0,0 +1,76 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace OneShelf.Videos.Database.Migrations.VideosDatabaseMigrations
+{
+ ///
+ public partial class Media11 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Topics",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ StaticChatId = table.Column(type: "bigint", nullable: true),
+ StaticTopicRootMessageIdOr0 = table.Column(type: "int", nullable: true),
+ LiveChatId = table.Column(type: "bigint", nullable: true),
+ LiveTopicId = table.Column(type: "int", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Topics", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Topics_LiveChats_LiveChatId",
+ column: x => x.LiveChatId,
+ principalTable: "LiveChats",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_Topics_LiveTopics_LiveTopicId_LiveChatId",
+ columns: x => new { x.LiveTopicId, x.LiveChatId },
+ principalTable: "LiveTopics",
+ principalColumns: new[] { "Id", "LiveChatId" });
+ table.ForeignKey(
+ name: "FK_Topics_StaticChats_StaticChatId",
+ column: x => x.StaticChatId,
+ principalTable: "StaticChats",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_Topics_StaticTopics_StaticChatId_StaticTopicRootMessageIdOr0",
+ columns: x => new { x.StaticChatId, x.StaticTopicRootMessageIdOr0 },
+ principalTable: "StaticTopics",
+ principalColumns: new[] { "StaticChatId", "RootMessageIdOr0" });
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Topics_LiveChatId",
+ table: "Topics",
+ column: "LiveChatId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Topics_LiveTopicId_LiveChatId",
+ table: "Topics",
+ columns: new[] { "LiveTopicId", "LiveChatId" },
+ unique: true,
+ filter: "[LiveTopicId] IS NOT NULL AND [LiveChatId] IS NOT NULL");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Topics_StaticChatId_StaticTopicRootMessageIdOr0",
+ table: "Topics",
+ columns: new[] { "StaticChatId", "StaticTopicRootMessageIdOr0" },
+ unique: true,
+ filter: "[StaticChatId] IS NOT NULL AND [StaticTopicRootMessageIdOr0] IS NOT NULL");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Topics");
+ }
+ }
+}
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs
index dbe20e18..cbdccb0d 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs
@@ -568,6 +568,41 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("StaticTopics");
});
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Topic", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("LiveChatId")
+ .HasColumnType("bigint");
+
+ b.Property("LiveTopicId")
+ .HasColumnType("int");
+
+ b.Property("StaticChatId")
+ .HasColumnType("bigint");
+
+ b.Property("StaticTopicRootMessageIdOr0")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LiveChatId");
+
+ b.HasIndex("LiveTopicId", "LiveChatId")
+ .IsUnique()
+ .HasFilter("[LiveTopicId] IS NOT NULL AND [LiveChatId] IS NOT NULL");
+
+ b.HasIndex("StaticChatId", "StaticTopicRootMessageIdOr0")
+ .IsUnique()
+ .HasFilter("[StaticChatId] IS NOT NULL AND [StaticTopicRootMessageIdOr0] IS NOT NULL");
+
+ b.ToTable("Topics");
+ });
+
modelBuilder.Entity("OneShelf.Videos.Database.Models.UploadedAlbum", b =>
{
b.Property("Id")
@@ -749,6 +784,33 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("StaticChat");
});
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Topic", b =>
+ {
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveChat", "LiveChat")
+ .WithMany("Topics")
+ .HasForeignKey("LiveChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticChat", "StaticChat")
+ .WithMany("Topics")
+ .HasForeignKey("StaticChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Live.LiveTopic", "LiveTopic")
+ .WithOne("Topic")
+ .HasForeignKey("OneShelf.Videos.Database.Models.Topic", "LiveTopicId", "LiveChatId");
+
+ b.HasOne("OneShelf.Videos.Database.Models.Static.StaticTopic", "StaticTopic")
+ .WithOne("Topic")
+ .HasForeignKey("OneShelf.Videos.Database.Models.Topic", "StaticChatId", "StaticTopicRootMessageIdOr0");
+
+ b.Navigation("LiveChat");
+
+ b.Navigation("LiveTopic");
+
+ b.Navigation("StaticChat");
+
+ b.Navigation("StaticTopic");
+ });
+
modelBuilder.Entity("OneShelf.Videos.Database.Models.UploadedAlbum", b =>
{
b.HasOne("OneShelf.Videos.Database.Models.Album", "Album")
@@ -783,6 +845,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("LiveTopics");
b.Navigation("Mediae");
+
+ b.Navigation("Topics");
});
modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveMedia", b =>
@@ -793,6 +857,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveTopic", b =>
{
b.Navigation("LiveMediae");
+
+ b.Navigation("Topic");
});
modelBuilder.Entity("OneShelf.Videos.Database.Models.Media", b =>
@@ -805,6 +871,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("Mediae");
b.Navigation("Messages");
+
+ b.Navigation("Topics");
});
modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChatFolder", b =>
@@ -820,6 +888,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticTopic", b =>
{
b.Navigation("StaticMessages");
+
+ b.Navigation("Topic");
});
#pragma warning restore 612, 618
}
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs
index a2d964e1..382317c7 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;
-using System.Text.Json.Serialization;
namespace OneShelf.Videos.Database.Models.Live;
@@ -13,4 +12,6 @@ public class LiveChat
public ICollection LiveTopics { get; set; }
public ICollection Mediae { get; set; }
+
+ public ICollection Topics { get; set; }
}
\ No newline at end of file
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveTopic.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveTopic.cs
index 0120f964..fb63b7a0 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveTopic.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveTopic.cs
@@ -14,4 +14,6 @@ public class LiveTopic
public string Title { get; set; }
public ICollection LiveMediae { get; set; }
+
+ public Topic? Topic { get; set; }
}
\ No newline at end of file
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticChat.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticChat.cs
index b50f92e8..f7eb2ee2 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticChat.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticChat.cs
@@ -21,4 +21,7 @@ public class StaticChat
[JsonIgnore]
public ICollection Mediae { get; set; }
+
+ [JsonIgnore]
+ public ICollection Topics { get; set; }
}
\ No newline at end of file
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticTopic.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticTopic.cs
index fcfc50dc..889b0027 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticTopic.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticTopic.cs
@@ -18,4 +18,6 @@ public class StaticTopic
public required string Title { get; set; }
public ICollection StaticMessages { get; set; }
+
+ public Topic? Topic { get; set; }
}
\ No newline at end of file
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Topic.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Topic.cs
index db54c5da..0ff920bd 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Topic.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Topic.cs
@@ -8,18 +8,14 @@ public class Topic
public int Id { get; set; }
public long? StaticChatId { get; set; }
- public int? StaticMessageId { get; set; }
+ public int? StaticTopicRootMessageIdOr0 { get; set; }
public StaticChat? StaticChat { get; set; }
- public StaticMessage? StaticMessage { get; set; }
+ public StaticTopic? StaticTopic { get; set; }
public long? LiveChatId { get; set; }
- public int? LiveMediaId { get; set; }
+ public int? LiveTopicId { get; set; }
public LiveChat? LiveChat { get; set; }
- public LiveMedia? LiveMedia { get; set; }
-
- public MediaType Type { get; set; }
-
- public UploadedItem? UploadedItem { get; set; }
+ public LiveTopic? LiveTopic { get; set; }
}
\ No newline at end of file
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs b/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs
index e9789908..1ffaa67d 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs
@@ -31,6 +31,7 @@ public VideosDatabase(DbContextOptions options)
public required DbSet LiveDownloadedItems { get; set; }
public required DbSet Mediae { get; set; }
+ public required DbSet Topics { get; set; }
public required DbSet UploadedItems { get; set; }
public required DbSet InventoryItems { get; set; }
@@ -238,5 +239,19 @@ when MimeType like 'image/%' then 'Photo'
.WithMany(x => x.StaticMessages)
.IsRequired(false)
.HasForeignKey(x => new { x.StaticChatId, x.StaticTopicRootMessageIdOr0 });
+
+ modelBuilder.Entity()
+ .HasOne(x => x.StaticTopic)
+ .WithOne(x => x.Topic)
+ .HasPrincipalKey(x => new { x.StaticChatId, x.RootMessageIdOr0 })
+ .HasForeignKey(x => new { x.StaticChatId, x.StaticTopicRootMessageIdOr0 })
+ .IsRequired(false);
+
+ modelBuilder.Entity()
+ .HasOne(x => x.LiveTopic)
+ .WithOne(x => x.Topic)
+ .HasPrincipalKey(x => new { x.Id, x.LiveChatId })
+ .HasForeignKey(x => new { x.LiveTopicId, x.LiveChatId })
+ .IsRequired(false);
}
}
\ No newline at end of file