From ac743c97879e7feff228f3e3bc56a2e73365272e Mon Sep 17 00:00:00 2001 From: Pavel Zhur Date: Sun, 29 Sep 2024 17:11:10 +0300 Subject: [PATCH] inventory items --- .../OneShelf.Videos.App/Program.cs | 1 + .../Services/Service2.cs | 67 +- .../20240929140421_Media21.Designer.cs | 916 +++++++++++++++++ .../Migrations/20240929140421_Media21.cs | 64 ++ .../20240929140903_Media22.Designer.cs | 919 ++++++++++++++++++ .../Migrations/20240929140903_Media22.cs | 30 + .../Migrations/VideosDatabaseModelSnapshot.cs | 16 +- .../Models/InventoryItem.cs | 54 +- 8 files changed, 2002 insertions(+), 65 deletions(-) create mode 100644 OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.Designer.cs create mode 100644 OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.cs create mode 100644 OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.Designer.cs create mode 100644 OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.cs diff --git a/OneShelf.Videos/OneShelf.Videos.App/Program.cs b/OneShelf.Videos/OneShelf.Videos.App/Program.cs index 31597fa9..5b399701 100644 --- a/OneShelf.Videos/OneShelf.Videos.App/Program.cs +++ b/OneShelf.Videos/OneShelf.Videos.App/Program.cs @@ -20,6 +20,7 @@ //await videosDatabase.Database.MigrateAsync(); +await service2.SaveInventory(); await liveDownloader.UpdateLive(true); await videosDatabase.AppendTopics(); await videosDatabase.AppendMediae(); diff --git a/OneShelf.Videos/OneShelf.Videos.BusinessLogic/Services/Service2.cs b/OneShelf.Videos/OneShelf.Videos.BusinessLogic/Services/Service2.cs index bdded131..3aa96015 100644 --- a/OneShelf.Videos/OneShelf.Videos.BusinessLogic/Services/Service2.cs +++ b/OneShelf.Videos/OneShelf.Videos.BusinessLogic/Services/Service2.cs @@ -37,33 +37,48 @@ public async Task SaveInventory() await _extendedGooglePhotosService.LoginAsync(); var items = await _extendedGooglePhotosService.GetMediaItemsAsync().ToListAsync(); _logger.LogInformation("{items} found.", items.Count); - _videosDatabase.InventoryItems.AddRange(items.Select(i => new InventoryItem + + var existingItems = await _videosDatabase.InventoryItems.ToDictionaryAsync(x => x.Id); + + foreach (var i in items) { - BaseUrl = i.baseUrl, - Description = i.description, - FileName = i.filename, - Id = i.id, - IsPhoto = i.isPhoto, - IsVideo = i.isVideo, - ProductUrl = i.productUrl, - SyncDate = i.syncDate, - MimeType = i.mimeType, - ContributorInfoDisplayName = i.contributorInfo?.displayName, - ContributorInfoProfilePictureBaseUrl = i.contributorInfo?.profilePictureBaseUrl, - MediaMetadataHeight = i.mediaMetadata.height, - MediaMetadataWidth = i.mediaMetadata.width, - MediaMetadataCreationTime = i.mediaMetadata.creationTime, - MediaMetadataPhotoApertureFNumber = i.mediaMetadata.photo?.apertureFNumber, - MediaMetadataPhotoExposureTime = i.mediaMetadata.photo?.exposureTime, - MediaMetadataPhotoFocalLength = i.mediaMetadata.photo?.focalLength, - MediaMetadataPhotoIsoEquivalent = i.mediaMetadata.photo?.isoEquivalent, - MediaMetadataPhotoCameraMake = i.mediaMetadata.photo?.cameraMake, - MediaMetadataPhotoCameraModel = i.mediaMetadata.photo?.cameraModel, - MediaMetadataVideoStatus = i.mediaMetadata.video?.status, - MediaMetadataVideoFps = i.mediaMetadata.video?.fps, - MediaMetadataVideoCameraMake = i.mediaMetadata.video?.cameraMake, - MediaMetadataVideoCameraModel = i.mediaMetadata.video?.cameraModel, - })); + var item = existingItems.GetValueOrDefault(i.id); + if (item == null) + { + item = new() + { + Id = i.id, + CreatedOn = DateTime.UtcNow, + }; + + _videosDatabase.InventoryItems.Add(item); + } + + item.BaseUrl = i.baseUrl; + item.Description = i.description; + item.FileName = i.filename; + item.IsPhoto = i.isPhoto; + item.IsVideo = i.isVideo; + item.ProductUrl = i.productUrl; + item.SyncDate = i.syncDate; + item.MimeType = i.mimeType; + item.ContributorInfoDisplayName = i.contributorInfo?.displayName; + item.ContributorInfoProfilePictureBaseUrl = i.contributorInfo?.profilePictureBaseUrl; + item.MediaMetadataHeight = i.mediaMetadata.height; + item.MediaMetadataWidth = i.mediaMetadata.width; + item.MediaMetadataCreationTime = i.mediaMetadata.creationTime; + item.MediaMetadataPhotoApertureFNumber = i.mediaMetadata.photo?.apertureFNumber; + item.MediaMetadataPhotoExposureTime = i.mediaMetadata.photo?.exposureTime; + item.MediaMetadataPhotoFocalLength = i.mediaMetadata.photo?.focalLength; + item.MediaMetadataPhotoIsoEquivalent = i.mediaMetadata.photo?.isoEquivalent; + item.MediaMetadataPhotoCameraMake = i.mediaMetadata.photo?.cameraMake; + item.MediaMetadataPhotoCameraModel = i.mediaMetadata.photo?.cameraModel; + item.MediaMetadataVideoStatus = i.mediaMetadata.video?.status; + item.MediaMetadataVideoFps = i.mediaMetadata.video?.fps; + item.MediaMetadataVideoCameraMake = i.mediaMetadata.video?.cameraMake; + item.MediaMetadataVideoCameraModel = i.mediaMetadata.video?.cameraModel; + } + _logger.LogInformation("Saving..."); await _videosDatabase.SaveChangesAsync(); _logger.LogInformation("Saved."); diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.Designer.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.Designer.cs new file mode 100644 index 00000000..e0887c2e --- /dev/null +++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.Designer.cs @@ -0,0 +1,916 @@ +// +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("20240929140421_Media21")] + partial class Media21 + { + /// + 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("TopicId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AlbumId"); + + b.HasIndex("TopicId"); + + b.ToTable("AlbumConstraints"); + }); + + modelBuilder.Entity("OneShelf.Videos.Database.Models.InventoryItem", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + 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("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("Id"); + + 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("LastInventoryExists") + .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("TopicId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("LiveChatId"); + + b.HasIndex("TopicId"); + + 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("PhotoPathTimestamp") + .HasColumnType("datetime2"); + + 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("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("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.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.HasOne("OneShelf.Videos.Database.Models.Topic", "Topic") + .WithMany("AlbumConstraints") + .HasForeignKey("TopicId"); + + b.Navigation("Album"); + + b.Navigation("Topic"); + }); + + 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.Topic", "Topic") + .WithMany("Mediae") + .HasForeignKey("TopicId"); + + 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"); + + b.Navigation("Topic"); + }); + + 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"); + }); + + modelBuilder.Entity("OneShelf.Videos.Database.Models.Topic", b => + { + b.Navigation("AlbumConstraints"); + + b.Navigation("Mediae"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.cs new file mode 100644 index 00000000..c289f236 --- /dev/null +++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140421_Media21.cs @@ -0,0 +1,64 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace OneShelf.Videos.Database.Migrations.VideosDatabaseMigrations +{ + /// + public partial class Media21 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_InventoryItems", + table: "InventoryItems"); + + migrationBuilder.DropColumn( + name: "DatabaseInventoryItemId", + table: "InventoryItems"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "InventoryItems", + type: "nvarchar(450)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AddPrimaryKey( + name: "PK_InventoryItems", + table: "InventoryItems", + column: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_InventoryItems", + table: "InventoryItems"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "InventoryItems", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(450)"); + + migrationBuilder.AddColumn( + name: "DatabaseInventoryItemId", + table: "InventoryItems", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddPrimaryKey( + name: "PK_InventoryItems", + table: "InventoryItems", + column: "DatabaseInventoryItemId"); + } + } +} diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.Designer.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.Designer.cs new file mode 100644 index 00000000..411535d2 --- /dev/null +++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.Designer.cs @@ -0,0 +1,919 @@ +// +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("20240929140903_Media22")] + partial class Media22 + { + /// + 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("TopicId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AlbumId"); + + b.HasIndex("TopicId"); + + b.ToTable("AlbumConstraints"); + }); + + modelBuilder.Entity("OneShelf.Videos.Database.Models.InventoryItem", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("BaseUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContributorInfoDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("ContributorInfoProfilePictureBaseUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .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("Id"); + + 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("LastInventoryExists") + .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("TopicId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("LiveChatId"); + + b.HasIndex("TopicId"); + + 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("PhotoPathTimestamp") + .HasColumnType("datetime2"); + + 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("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("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.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.HasOne("OneShelf.Videos.Database.Models.Topic", "Topic") + .WithMany("AlbumConstraints") + .HasForeignKey("TopicId"); + + b.Navigation("Album"); + + b.Navigation("Topic"); + }); + + 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.Topic", "Topic") + .WithMany("Mediae") + .HasForeignKey("TopicId"); + + 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"); + + b.Navigation("Topic"); + }); + + 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"); + }); + + modelBuilder.Entity("OneShelf.Videos.Database.Models.Topic", b => + { + b.Navigation("AlbumConstraints"); + + b.Navigation("Mediae"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.cs new file mode 100644 index 00000000..187a415f --- /dev/null +++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/20240929140903_Media22.cs @@ -0,0 +1,30 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace OneShelf.Videos.Database.Migrations.VideosDatabaseMigrations +{ + /// + public partial class Media22 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CreatedOn", + table: "InventoryItems", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CreatedOn", + table: "InventoryItems"); + } + } +} diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs index df5b356c..03422a24 100644 --- a/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs +++ b/OneShelf.Videos/OneShelf.Videos.Database/Migrations/VideosDatabaseModelSnapshot.cs @@ -79,11 +79,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("OneShelf.Videos.Database.Models.InventoryItem", b => { - b.Property("DatabaseInventoryItemId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DatabaseInventoryItemId")); + b.Property("Id") + .HasColumnType("nvarchar(450)"); b.Property("BaseUrl") .IsRequired() @@ -95,6 +92,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ContributorInfoProfilePictureBaseUrl") .HasColumnType("nvarchar(max)"); + b.Property("CreatedOn") + .HasColumnType("datetime2"); + b.Property("Description") .HasColumnType("nvarchar(max)"); @@ -102,10 +102,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Id") - .IsRequired() - .HasColumnType("nvarchar(max)"); - b.Property("IsPhoto") .HasColumnType("bit"); @@ -162,7 +158,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SyncDate") .HasColumnType("datetime2"); - b.HasKey("DatabaseInventoryItemId"); + b.HasKey("Id"); b.ToTable("InventoryItems"); }); diff --git a/OneShelf.Videos/OneShelf.Videos.Database/Models/InventoryItem.cs b/OneShelf.Videos/OneShelf.Videos.Database/Models/InventoryItem.cs index 2af506cf..76a49300 100644 --- a/OneShelf.Videos/OneShelf.Videos.Database/Models/InventoryItem.cs +++ b/OneShelf.Videos/OneShelf.Videos.Database/Models/InventoryItem.cs @@ -1,34 +1,30 @@ -using System.ComponentModel.DataAnnotations; - -namespace OneShelf.Videos.Database.Models; +namespace OneShelf.Videos.Database.Models; public class InventoryItem { - [Key] - public int DatabaseInventoryItemId { get; set; } - public required string Id { get; init; } - public required string BaseUrl { get; set; } - public required string? Description { get; set; } - public required string FileName { get; set; } - public required bool IsPhoto { get; set; } - public required bool IsVideo { get; set; } - public required string ProductUrl { get; set; } - public required DateTime SyncDate { get; set; } - public required string MimeType { get; set; } - public required string? ContributorInfoDisplayName { get; set; } - public required string? ContributorInfoProfilePictureBaseUrl { get; set; } - public required string? MediaMetadataHeight { get; set; } - public required string? MediaMetadataWidth { get; set; } - public required DateTime MediaMetadataCreationTime { get; set; } - public required float? MediaMetadataPhotoApertureFNumber { get; set; } - public required string? MediaMetadataPhotoExposureTime { get; set; } - public required float? MediaMetadataPhotoFocalLength { get; set; } - public required int? MediaMetadataPhotoIsoEquivalent { get; set; } - public required string? MediaMetadataPhotoCameraMake { get; set; } - public required string? MediaMetadataPhotoCameraModel { get; set; } - public required string? MediaMetadataVideoStatus { get; set; } - public required double? MediaMetadataVideoFps { get; set; } - public required string? MediaMetadataVideoCameraMake { get; set; } - public required string? MediaMetadataVideoCameraModel { get; set; } + public required DateTime CreatedOn { get; init; } + public string BaseUrl { get; set; } + public string? Description { get; set; } + public string FileName { get; set; } + public bool IsPhoto { get; set; } + public bool IsVideo { get; set; } + public string ProductUrl { get; set; } + public DateTime SyncDate { get; set; } + public string MimeType { get; set; } + public string? ContributorInfoDisplayName { get; set; } + public string? ContributorInfoProfilePictureBaseUrl { get; set; } + public string? MediaMetadataHeight { get; set; } + public string? MediaMetadataWidth { get; set; } + public DateTime MediaMetadataCreationTime { get; set; } + public float? MediaMetadataPhotoApertureFNumber { get; set; } + public string? MediaMetadataPhotoExposureTime { get; set; } + public float? MediaMetadataPhotoFocalLength { get; set; } + public int? MediaMetadataPhotoIsoEquivalent { get; set; } + public string? MediaMetadataPhotoCameraMake { get; set; } + public string? MediaMetadataPhotoCameraModel { get; set; } + public string? MediaMetadataVideoStatus { get; set; } + public double? MediaMetadataVideoFps { get; set; } + public string? MediaMetadataVideoCameraMake { get; set; } + public string? MediaMetadataVideoCameraModel { get; set; } } \ No newline at end of file