diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240927135124_Media2.Designer.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240927135124_Media2.Designer.cs
new file mode 100644
index 00000000..e09e82ea
--- /dev/null
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240927135124_Media2.Designer.cs
@@ -0,0 +1,821 @@
+//
+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("20240927135124_Media2")]
+ partial class Media2
+ {
+ ///
+ 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.HasIndex("StaticTopicId");
+
+ 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("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.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("StaticTopicId")
+ .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("StaticTopicId");
+
+ b.ToTable("StaticMessages");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticTopic", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("OriginalTitle")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("RootMessageIdOr0")
+ .HasColumnType("int");
+
+ b.Property("StaticChatId")
+ .HasColumnType("bigint");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("StaticChatId", "RootMessageIdOr0")
+ .IsUnique();
+
+ b.ToTable("StaticTopics");
+ });
+
+ 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("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("StaticChatId")
+ .HasColumnType("bigint");
+
+ b.Property("StaticMessageId")
+ .HasColumnType("int");
+
+ 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.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.HasOne("OneShelf.Videos.Database.Models.Static.StaticTopic", "StaticTopic")
+ .WithMany("AlbumConstraints")
+ .HasForeignKey("StaticTopicId");
+
+ b.Navigation("Album");
+
+ b.Navigation("StaticTopic");
+ });
+
+ 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("StaticTopicId");
+
+ 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.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.Album", b =>
+ {
+ b.Navigation("Constraints");
+
+ b.Navigation("UploadedAlbum");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveChat", b =>
+ {
+ b.Navigation("LiveTopics");
+
+ b.Navigation("Mediae");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveMedia", b =>
+ {
+ b.Navigation("Media");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveTopic", b =>
+ {
+ b.Navigation("LiveMediae");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChat", b =>
+ {
+ b.Navigation("Mediae");
+
+ b.Navigation("Messages");
+ });
+
+ 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("AlbumConstraints");
+
+ b.Navigation("StaticMessages");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240927135124_Media2.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240927135124_Media2.cs
new file mode 100644
index 00000000..16c24b25
--- /dev/null
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240927135124_Media2.cs
@@ -0,0 +1,76 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace OneShelf.Videos.Database.Migrations.VideosDatabaseMigrations
+{
+ ///
+ public partial class Media2 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Mediae",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ StaticChatId = table.Column(type: "bigint", nullable: true),
+ StaticMessageId = table.Column(type: "int", nullable: true),
+ LiveChatId = table.Column(type: "bigint", nullable: true),
+ LiveMediaId = table.Column(type: "int", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Mediae", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Mediae_LiveChats_LiveChatId",
+ column: x => x.LiveChatId,
+ principalTable: "LiveChats",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_Mediae_LiveMediae_LiveMediaId_LiveChatId",
+ columns: x => new { x.LiveMediaId, x.LiveChatId },
+ principalTable: "LiveMediae",
+ principalColumns: new[] { "Id", "LiveTopicLiveChatId" });
+ table.ForeignKey(
+ name: "FK_Mediae_StaticChats_StaticChatId",
+ column: x => x.StaticChatId,
+ principalTable: "StaticChats",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_Mediae_StaticMessages_StaticChatId_StaticMessageId",
+ columns: x => new { x.StaticChatId, x.StaticMessageId },
+ principalTable: "StaticMessages",
+ principalColumns: new[] { "StaticChatId", "Id" });
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Mediae_LiveChatId",
+ table: "Mediae",
+ column: "LiveChatId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Mediae_LiveMediaId_LiveChatId",
+ table: "Mediae",
+ columns: new[] { "LiveMediaId", "LiveChatId" },
+ unique: true,
+ filter: "[LiveMediaId] IS NOT NULL AND [LiveChatId] IS NOT NULL");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Mediae_StaticChatId_StaticMessageId",
+ table: "Mediae",
+ columns: new[] { "StaticChatId", "StaticMessageId" },
+ unique: true,
+ filter: "[StaticChatId] IS NOT NULL AND [StaticMessageId] IS NOT NULL");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Mediae");
+ }
+ }
+}
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs
index eaae23b0..97d1c8f9 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs
@@ -301,6 +301,41 @@ protected override void BuildModel(ModelBuilder modelBuilder)
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.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")
@@ -653,6 +688,33 @@ protected override void BuildModel(ModelBuilder modelBuilder)
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")
@@ -713,6 +775,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveChat", b =>
{
b.Navigation("LiveTopics");
+
+ b.Navigation("Mediae");
+ });
+
+ modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveMedia", b =>
+ {
+ b.Navigation("Media");
});
modelBuilder.Entity("OneShelf.Videos.Database.Models.Live.LiveTopic", b =>
@@ -722,6 +791,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("OneShelf.Videos.Database.Models.Static.StaticChat", b =>
{
+ b.Navigation("Mediae");
+
b.Navigation("Messages");
});
@@ -730,6 +801,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
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("AlbumConstraints");
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs
index 11fc3115..a2d964e1 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveChat.cs
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
+using System.Text.Json.Serialization;
namespace OneShelf.Videos.Database.Models.Live;
@@ -10,4 +11,6 @@ public class LiveChat
public string Title { get; set; }
public ICollection LiveTopics { get; set; }
+
+ public ICollection Mediae { get; set; }
}
\ No newline at end of file
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveMedia.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveMedia.cs
index 0498233b..221f39e3 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveMedia.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Live/LiveMedia.cs
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
+using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore;
namespace OneShelf.Videos.Database.Models.Live;
@@ -17,6 +18,8 @@ public class LiveMedia
public LiveMediaType Type { get; set; }
+ public Media? Media { get; set; }
+
public DateTime MessageDate { get; set; }
public bool IsForwarded { get; set; }
public DateTime MediaDate { get; set; }
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Media.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Media.cs
index f8cfd84a..cc6f520d 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Media.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Media.cs
@@ -1,14 +1,21 @@
-using OneShelf.Videos.Database.Models.Static;
+using OneShelf.Videos.Database.Models.Live;
+using OneShelf.Videos.Database.Models.Static;
namespace OneShelf.Videos.Database.Models;
-//public class Media
-//{
-// public int Id { get; set; }
+public class Media
+{
+ public int Id { get; set; }
-// public long? StaticChatId { get; init; }
-// public int? StaticMessageId { get; init; }
+ public long? StaticChatId { get; set; }
+ public int? StaticMessageId { get; set; }
-// public StaticChat? StaticChat { get; init; }
-// public StaticMessage? StaticMessage { get; init; }
-//}
\ No newline at end of file
+ public StaticChat? StaticChat { get; set; }
+ public StaticMessage? StaticMessage { get; set; }
+
+ public long? LiveChatId { get; set; }
+ public int? LiveMediaId { get; set; }
+
+ public LiveChat? LiveChat { get; set; }
+ public LiveMedia? LiveMedia { 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 8e960163..b50f92e8 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticChat.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticChat.cs
@@ -19,6 +19,6 @@ public class StaticChat
[JsonIgnore]
public StaticChatFolder StaticChatFolder { get; set; } = null!;
- //[JsonIgnore]
- //public ICollection Mediae { get; set; }
+ [JsonIgnore]
+ public ICollection Mediae { get; set; }
}
\ No newline at end of file
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticMessage.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticMessage.cs
index 6e93afbd..203db445 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticMessage.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/Static/StaticMessage.cs
@@ -22,8 +22,8 @@ public class StaticMessage
[JsonIgnore]
public StaticMessageSelectedType? SelectedType { get; set; }
- //[JsonIgnore]
- //public Media? Media { get; set; }
+ [JsonIgnore]
+ public Media? Media { get; set; }
public required int Id { get; set; }
public int? MessageId { get; set; }
diff --git a/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs b/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs
index 34ad5428..985ca023 100644
--- a/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs
+++ b/OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs
@@ -30,6 +30,8 @@ public VideosDatabase(DbContextOptions options)
public required DbSet LiveMediae { get; set; }
public required DbSet LiveDownloadedItems { get; set; }
+ public required DbSet Mediae { get; set; }
+
public required DbSet UploadedItems { get; set; }
public required DbSet InventoryItems { get; set; }
public required DbSet Albums { get; set; }
@@ -178,5 +180,19 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity()
.Property(x => x.Type)
.HasConversion();
+
+ modelBuilder.Entity()
+ .HasOne(x => x.StaticMessage)
+ .WithOne(x => x.Media)
+ .HasPrincipalKey(x => new { x.StaticChatId, x.Id })
+ .HasForeignKey(x => new { x.StaticChatId, x.StaticMessageId })
+ .IsRequired(false);
+
+ modelBuilder.Entity()
+ .HasOne(x => x.LiveMedia)
+ .WithOne(x => x.Media)
+ .HasPrincipalKey(x => new { x.Id, x.LiveTopicLiveChatId })
+ .HasForeignKey(x => new { x.LiveMediaId, x.LiveChatId })
+ .IsRequired(false);
}
}
\ No newline at end of file