From 169ec3d919c0fb1457d5a4d9e32d22bf64e6c834 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Fri, 20 May 2022 22:49:17 -0700 Subject: [PATCH] Add index for URls --- Teknik/Areas/Paste/Models/Paste.cs | 6 +- Teknik/Areas/Shortener/Models/ShortenedUrl.cs | 8 +- Teknik/Areas/Upload/Models/Upload.cs | 6 +- Teknik/Areas/Vault/Models/Vault.cs | 8 +- .../20220521053202_MaxUrlLength.Designer.cs | 1042 ++++++++++++++++ .../Migrations/20220521053202_MaxUrlLength.cs | 113 ++ .../20220521053504_UrlIndex.Designer.cs | 1050 +++++++++++++++++ .../Migrations/20220521053504_UrlIndex.cs | 49 + .../Migrations/TeknikEntitiesModelSnapshot.cs | 45 +- 9 files changed, 2294 insertions(+), 33 deletions(-) create mode 100644 Teknik/Data/Migrations/20220521053202_MaxUrlLength.Designer.cs create mode 100644 Teknik/Data/Migrations/20220521053202_MaxUrlLength.cs create mode 100644 Teknik/Data/Migrations/20220521053504_UrlIndex.Designer.cs create mode 100644 Teknik/Data/Migrations/20220521053504_UrlIndex.cs diff --git a/Teknik/Areas/Paste/Models/Paste.cs b/Teknik/Areas/Paste/Models/Paste.cs index d22048e..f53ff4e 100644 --- a/Teknik/Areas/Paste/Models/Paste.cs +++ b/Teknik/Areas/Paste/Models/Paste.cs @@ -1,5 +1,7 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,6 +11,7 @@ using Teknik.Models; namespace Teknik.Areas.Paste.Models { + [Index(nameof(Url))] public class Paste { public int PasteId { get; set; } @@ -23,6 +26,7 @@ namespace Teknik.Areas.Paste.Models public DateTime DateEdited { get; set; } + [MaxLength(250)] [CaseSensitive] public string Url { get; set; } diff --git a/Teknik/Areas/Shortener/Models/ShortenedUrl.cs b/Teknik/Areas/Shortener/Models/ShortenedUrl.cs index 6425ebe..3b65757 100644 --- a/Teknik/Areas/Shortener/Models/ShortenedUrl.cs +++ b/Teknik/Areas/Shortener/Models/ShortenedUrl.cs @@ -1,5 +1,7 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; using Teknik.Areas.Users.Models; @@ -7,6 +9,7 @@ using Teknik.Attributes; namespace Teknik.Areas.Shortener.Models { + [Index(nameof(ShortUrl))] public class ShortenedUrl { public int ShortenedUrlId { get; set; } @@ -14,7 +17,8 @@ namespace Teknik.Areas.Shortener.Models public int? UserId { get; set; } public virtual User User { get; set; } - + + [MaxLength(250)] [CaseSensitive] public string ShortUrl { get; set; } diff --git a/Teknik/Areas/Upload/Models/Upload.cs b/Teknik/Areas/Upload/Models/Upload.cs index 1033ebb..39934a1 100644 --- a/Teknik/Areas/Upload/Models/Upload.cs +++ b/Teknik/Areas/Upload/Models/Upload.cs @@ -1,5 +1,7 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; using Teknik.Areas.Users.Models; @@ -7,6 +9,7 @@ using Teknik.Attributes; namespace Teknik.Areas.Upload.Models { + [Index(nameof(Url))] public class Upload { public int UploadId { get; set; } @@ -19,6 +22,7 @@ namespace Teknik.Areas.Upload.Models public DateTime DateUploaded { get; set; } + [MaxLength(250)] [CaseSensitive] public string Url { get; set; } diff --git a/Teknik/Areas/Vault/Models/Vault.cs b/Teknik/Areas/Vault/Models/Vault.cs index 7d7bb6b..48f9f73 100644 --- a/Teknik/Areas/Vault/Models/Vault.cs +++ b/Teknik/Areas/Vault/Models/Vault.cs @@ -1,10 +1,14 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; +using Teknik.Attributes; namespace Teknik.Areas.Vault.Models { + [Index(nameof(Url))] public class Vault { public int VaultId { get; set; } @@ -13,6 +17,8 @@ namespace Teknik.Areas.Vault.Models public virtual Users.Models.User User { get; set; } + [MaxLength(250)] + [CaseSensitive] public string Url { get; set; } public string Title { get; set; } diff --git a/Teknik/Data/Migrations/20220521053202_MaxUrlLength.Designer.cs b/Teknik/Data/Migrations/20220521053202_MaxUrlLength.Designer.cs new file mode 100644 index 0000000..ea17792 --- /dev/null +++ b/Teknik/Data/Migrations/20220521053202_MaxUrlLength.Designer.cs @@ -0,0 +1,1042 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Teknik.Data; + +namespace Teknik.Data.Migrations +{ + [DbContext(typeof(TeknikEntities))] + [Migration("20220521053202_MaxUrlLength")] + partial class MaxUrlLength + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.7") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Teknik.Areas.Billing.Models.Customer", b => + { + b.Property("CustomerId") + .HasColumnType("nvarchar(450)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("CustomerId"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.Property("BlogId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("BlogId"); + + b.HasIndex("UserId"); + + b.ToTable("Blogs"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.Property("BlogPostId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article") + .HasColumnType("nvarchar(max)"); + + b.Property("BlogId") + .HasColumnType("int"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("DatePublished") + .HasColumnType("datetime2"); + + b.Property("Published") + .HasColumnType("bit"); + + b.Property("System") + .HasColumnType("bit"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("BlogPostId"); + + b.HasIndex("BlogId"); + + b.ToTable("BlogPosts"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b => + { + b.Property("BlogPostCommentId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article") + .HasColumnType("nvarchar(max)"); + + b.Property("BlogPostId") + .HasColumnType("int"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("BlogPostCommentId"); + + b.HasIndex("BlogPostId"); + + b.HasIndex("UserId"); + + b.ToTable("BlogPostComments"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b => + { + b.Property("BlogPostTagId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlogPostId") + .HasColumnType("int"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("BlogPostTagId"); + + b.HasIndex("BlogPostId"); + + b.ToTable("BlogPostTags"); + }); + + modelBuilder.Entity("Teknik.Areas.Contact.Models.Contact", b => + { + b.Property("ContactId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Subject") + .HasColumnType("nvarchar(max)"); + + b.HasKey("ContactId"); + + b.ToTable("Contact"); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.Property("PasteId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlockSize") + .HasColumnType("int"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("DeleteKey") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("ExpireDate") + .HasColumnType("datetime2"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("HashedPassword") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("IV") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("Key") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("KeySize") + .HasColumnType("int"); + + b.Property("MaxViews") + .HasColumnType("int"); + + b.Property("Syntax") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("Views") + .HasColumnType("int"); + + b.HasKey("PasteId"); + + b.HasIndex("UserId"); + + b.ToTable("Pastes"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.Podcast", b => + { + b.Property("PodcastId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("DatePublished") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Episode") + .HasColumnType("int"); + + b.Property("Published") + .HasColumnType("bit"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("PodcastId"); + + b.ToTable("Podcasts"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b => + { + b.Property("PodcastCommentId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article") + .HasColumnType("nvarchar(max)"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("PodcastId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("PodcastCommentId"); + + b.HasIndex("PodcastId"); + + b.HasIndex("UserId"); + + b.ToTable("PodcastComments"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b => + { + b.Property("PodcastFileId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ContentLength") + .HasColumnType("bigint"); + + b.Property("ContentType") + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("Path") + .HasColumnType("nvarchar(max)"); + + b.Property("PodcastId") + .HasColumnType("int"); + + b.Property("Size") + .HasColumnType("int"); + + b.HasKey("PodcastFileId"); + + b.HasIndex("PodcastId"); + + b.ToTable("PodcastFiles"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b => + { + b.Property("PodcastTagId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("PodcastId") + .HasColumnType("int"); + + b.HasKey("PodcastTagId"); + + b.HasIndex("PodcastId"); + + b.ToTable("PodcastTags"); + }); + + modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b => + { + b.Property("ShortenedUrlId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded") + .HasColumnType("datetime2"); + + b.Property("OriginalUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("ShortUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("Views") + .HasColumnType("int"); + + b.HasKey("ShortenedUrlId"); + + b.HasIndex("UserId"); + + b.ToTable("ShortenedUrls"); + }); + + modelBuilder.Entity("Teknik.Areas.Stats.Models.Takedown", b => + { + b.Property("TakedownId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ActionTaken") + .HasColumnType("nvarchar(max)"); + + b.Property("DateActionTaken") + .HasColumnType("datetime2"); + + b.Property("DateRequested") + .HasColumnType("datetime2"); + + b.Property("Reason") + .HasColumnType("nvarchar(max)"); + + b.Property("Requester") + .HasColumnType("nvarchar(max)"); + + b.Property("RequesterContact") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TakedownId"); + + b.ToTable("Takedowns"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.Property("UploadId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlockSize") + .HasColumnType("int"); + + b.Property("ContentLength") + .HasColumnType("bigint"); + + b.Property("ContentType") + .HasColumnType("nvarchar(max)"); + + b.Property("DateUploaded") + .HasColumnType("datetime2"); + + b.Property("DeleteKey") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("Downloads") + .HasColumnType("int"); + + b.Property("ExpireDate") + .HasColumnType("datetime2"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("IV") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("Key") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("KeySize") + .HasColumnType("int"); + + b.Property("MaxDownloads") + .HasColumnType("int"); + + b.Property("Takedown_TakedownId") + .HasColumnType("int"); + + b.Property("Url") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("UploadId"); + + b.HasIndex("Takedown_TakedownId"); + + b.HasIndex("UserId"); + + b.ToTable("Uploads"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.Feature", b => + { + b.Property("FeatureId") + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("FeatureId"); + + b.ToTable("Features"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b => + { + b.Property("InviteCodeId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Active") + .HasColumnType("bit"); + + b.Property("ClaimedUserId") + .HasColumnType("int"); + + b.Property("Code") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.HasKey("InviteCodeId"); + + b.HasIndex("ClaimedUserId") + .IsUnique() + .HasFilter("[ClaimedUserId] IS NOT NULL"); + + b.HasIndex("OwnerId"); + + b.ToTable("InviteCodes"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Username") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b => + { + b.Property("UserFeatureId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("FeatureId") + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("UserFeatureId"); + + b.HasIndex("FeatureId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFeatures"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.Property("VaultId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateCreated") + .HasColumnType("datetime2"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("Views") + .HasColumnType("int"); + + b.HasKey("VaultId"); + + b.HasIndex("UserId"); + + b.ToTable("Vaults"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b => + { + b.Property("VaultItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("VaultId") + .HasColumnType("int"); + + b.HasKey("VaultItemId"); + + b.HasIndex("VaultId"); + + b.ToTable("VaultItems"); + + b.HasDiscriminator("Discriminator").HasValue("VaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b => + { + b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem"); + + b.Property("PasteId") + .HasColumnType("int"); + + b.HasIndex("PasteId"); + + b.HasDiscriminator().HasValue("PasteVaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b => + { + b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem"); + + b.Property("UploadId") + .HasColumnType("int"); + + b.HasIndex("UploadId"); + + b.HasDiscriminator().HasValue("UploadVaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Billing.Models.Customer", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithOne("BillingCustomer") + .HasForeignKey("Teknik.Areas.Billing.Models.Customer", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.HasOne("Teknik.Areas.Blog.Models.Blog", "Blog") + .WithMany("BlogPosts") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b => + { + b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost") + .WithMany("Comments") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("BlogPost"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b => + { + b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost") + .WithMany("Tags") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BlogPost"); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Pastes") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Comments") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Podcast"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Files") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Podcast"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Tags") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Podcast"); + }); + + modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("ShortenedUrls") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.HasOne("Teknik.Areas.Stats.Models.Takedown", null) + .WithMany("Attachments") + .HasForeignKey("Takedown_TakedownId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Uploads") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "ClaimedUser") + .WithOne("ClaimedInviteCode") + .HasForeignKey("Teknik.Areas.Users.Models.InviteCode", "ClaimedUserId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "Owner") + .WithMany("OwnedInviteCodes") + .HasForeignKey("OwnerId"); + + b.Navigation("ClaimedUser"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.OwnsOne("Teknik.Areas.Users.Models.BlogSettings", "BlogSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Description") + .HasColumnType("nvarchar(max)") + .HasColumnName("Description"); + + b1.Property("Title") + .HasColumnType("nvarchar(max)") + .HasColumnName("Title"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.OwnsOne("Teknik.Areas.Users.Models.UploadSettings", "UploadSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Encrypt") + .HasColumnType("bit") + .HasColumnName("Encrypt"); + + b1.Property("ExpirationLength") + .HasColumnType("int") + .HasColumnName("ExpirationLength"); + + b1.Property("ExpirationUnit") + .HasColumnType("int") + .HasColumnName("ExpirationUnit"); + + b1.Property("MaxUploadFileSize") + .HasColumnType("bigint") + .HasColumnName("MaxUploadFileSize"); + + b1.Property("MaxUploadStorage") + .HasColumnType("bigint") + .HasColumnName("MaxUploadStorage"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.OwnsOne("Teknik.Areas.Users.Models.UserSettings", "UserSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("About") + .HasColumnType("nvarchar(max)") + .HasColumnName("About"); + + b1.Property("Quote") + .HasColumnType("nvarchar(max)") + .HasColumnName("Quote"); + + b1.Property("Website") + .HasColumnType("nvarchar(max)") + .HasColumnName("Website"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("BlogSettings"); + + b.Navigation("UploadSettings"); + + b.Navigation("UserSettings"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b => + { + b.HasOne("Teknik.Areas.Users.Models.Feature", "Feature") + .WithMany() + .HasForeignKey("FeatureId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Features") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Feature"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Vaults") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b => + { + b.HasOne("Teknik.Areas.Vault.Models.Vault", "Vault") + .WithMany("VaultItems") + .HasForeignKey("VaultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Vault"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b => + { + b.HasOne("Teknik.Areas.Paste.Models.Paste", "Paste") + .WithMany("PasteVaultItems") + .HasForeignKey("PasteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Paste"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b => + { + b.HasOne("Teknik.Areas.Upload.Models.Upload", "Upload") + .WithMany("UploadVaultItems") + .HasForeignKey("UploadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Upload"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.Navigation("BlogPosts"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.Navigation("Comments"); + + b.Navigation("Tags"); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.Navigation("PasteVaultItems"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.Podcast", b => + { + b.Navigation("Comments"); + + b.Navigation("Files"); + + b.Navigation("Tags"); + }); + + modelBuilder.Entity("Teknik.Areas.Stats.Models.Takedown", b => + { + b.Navigation("Attachments"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.Navigation("UploadVaultItems"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.Navigation("BillingCustomer"); + + b.Navigation("ClaimedInviteCode"); + + b.Navigation("Features"); + + b.Navigation("OwnedInviteCodes"); + + b.Navigation("Pastes"); + + b.Navigation("ShortenedUrls"); + + b.Navigation("Uploads"); + + b.Navigation("Vaults"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.Navigation("VaultItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Teknik/Data/Migrations/20220521053202_MaxUrlLength.cs b/Teknik/Data/Migrations/20220521053202_MaxUrlLength.cs new file mode 100644 index 0000000..805c09d --- /dev/null +++ b/Teknik/Data/Migrations/20220521053202_MaxUrlLength.cs @@ -0,0 +1,113 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Teknik.Data.Migrations +{ + public partial class MaxUrlLength : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Transactions"); + + migrationBuilder.AlterColumn( + name: "Url", + table: "Vaults", + type: "nvarchar(250)", + maxLength: 250, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Url", + table: "Uploads", + type: "nvarchar(250)", + maxLength: 250, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ShortUrl", + table: "ShortenedUrls", + type: "nvarchar(250)", + maxLength: 250, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Url", + table: "Pastes", + type: "nvarchar(250)", + maxLength: 250, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Url", + table: "Vaults", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(250)", + oldMaxLength: 250, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Url", + table: "Uploads", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(250)", + oldMaxLength: 250, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ShortUrl", + table: "ShortenedUrls", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(250)", + oldMaxLength: 250, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Url", + table: "Pastes", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(250)", + oldMaxLength: 250, + oldNullable: true); + + migrationBuilder.CreateTable( + name: "Transactions", + columns: table => new + { + TransactionId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Amount = table.Column(type: "decimal(19,5)", nullable: false), + Currency = table.Column(type: "int", nullable: false), + DateSent = table.Column(type: "datetime2", nullable: false), + Reason = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Transactions", x => x.TransactionId); + }); + } + } +} diff --git a/Teknik/Data/Migrations/20220521053504_UrlIndex.Designer.cs b/Teknik/Data/Migrations/20220521053504_UrlIndex.Designer.cs new file mode 100644 index 0000000..272f6c1 --- /dev/null +++ b/Teknik/Data/Migrations/20220521053504_UrlIndex.Designer.cs @@ -0,0 +1,1050 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Teknik.Data; + +namespace Teknik.Data.Migrations +{ + [DbContext(typeof(TeknikEntities))] + [Migration("20220521053504_UrlIndex")] + partial class UrlIndex + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.7") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Teknik.Areas.Billing.Models.Customer", b => + { + b.Property("CustomerId") + .HasColumnType("nvarchar(450)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("CustomerId"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.Property("BlogId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("BlogId"); + + b.HasIndex("UserId"); + + b.ToTable("Blogs"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.Property("BlogPostId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article") + .HasColumnType("nvarchar(max)"); + + b.Property("BlogId") + .HasColumnType("int"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("DatePublished") + .HasColumnType("datetime2"); + + b.Property("Published") + .HasColumnType("bit"); + + b.Property("System") + .HasColumnType("bit"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("BlogPostId"); + + b.HasIndex("BlogId"); + + b.ToTable("BlogPosts"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b => + { + b.Property("BlogPostCommentId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article") + .HasColumnType("nvarchar(max)"); + + b.Property("BlogPostId") + .HasColumnType("int"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("BlogPostCommentId"); + + b.HasIndex("BlogPostId"); + + b.HasIndex("UserId"); + + b.ToTable("BlogPostComments"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b => + { + b.Property("BlogPostTagId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlogPostId") + .HasColumnType("int"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("BlogPostTagId"); + + b.HasIndex("BlogPostId"); + + b.ToTable("BlogPostTags"); + }); + + modelBuilder.Entity("Teknik.Areas.Contact.Models.Contact", b => + { + b.Property("ContactId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Subject") + .HasColumnType("nvarchar(max)"); + + b.HasKey("ContactId"); + + b.ToTable("Contact"); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.Property("PasteId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlockSize") + .HasColumnType("int"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("DeleteKey") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("ExpireDate") + .HasColumnType("datetime2"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("HashedPassword") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("IV") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("Key") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("KeySize") + .HasColumnType("int"); + + b.Property("MaxViews") + .HasColumnType("int"); + + b.Property("Syntax") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("Views") + .HasColumnType("int"); + + b.HasKey("PasteId"); + + b.HasIndex("Url"); + + b.HasIndex("UserId"); + + b.ToTable("Pastes"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.Podcast", b => + { + b.Property("PodcastId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("DatePublished") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Episode") + .HasColumnType("int"); + + b.Property("Published") + .HasColumnType("bit"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("PodcastId"); + + b.ToTable("Podcasts"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b => + { + b.Property("PodcastCommentId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article") + .HasColumnType("nvarchar(max)"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("DatePosted") + .HasColumnType("datetime2"); + + b.Property("PodcastId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("PodcastCommentId"); + + b.HasIndex("PodcastId"); + + b.HasIndex("UserId"); + + b.ToTable("PodcastComments"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b => + { + b.Property("PodcastFileId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ContentLength") + .HasColumnType("bigint"); + + b.Property("ContentType") + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("Path") + .HasColumnType("nvarchar(max)"); + + b.Property("PodcastId") + .HasColumnType("int"); + + b.Property("Size") + .HasColumnType("int"); + + b.HasKey("PodcastFileId"); + + b.HasIndex("PodcastId"); + + b.ToTable("PodcastFiles"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b => + { + b.Property("PodcastTagId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("PodcastId") + .HasColumnType("int"); + + b.HasKey("PodcastTagId"); + + b.HasIndex("PodcastId"); + + b.ToTable("PodcastTags"); + }); + + modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b => + { + b.Property("ShortenedUrlId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded") + .HasColumnType("datetime2"); + + b.Property("OriginalUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("ShortUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("Views") + .HasColumnType("int"); + + b.HasKey("ShortenedUrlId"); + + b.HasIndex("ShortUrl"); + + b.HasIndex("UserId"); + + b.ToTable("ShortenedUrls"); + }); + + modelBuilder.Entity("Teknik.Areas.Stats.Models.Takedown", b => + { + b.Property("TakedownId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ActionTaken") + .HasColumnType("nvarchar(max)"); + + b.Property("DateActionTaken") + .HasColumnType("datetime2"); + + b.Property("DateRequested") + .HasColumnType("datetime2"); + + b.Property("Reason") + .HasColumnType("nvarchar(max)"); + + b.Property("Requester") + .HasColumnType("nvarchar(max)"); + + b.Property("RequesterContact") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TakedownId"); + + b.ToTable("Takedowns"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.Property("UploadId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlockSize") + .HasColumnType("int"); + + b.Property("ContentLength") + .HasColumnType("bigint"); + + b.Property("ContentType") + .HasColumnType("nvarchar(max)"); + + b.Property("DateUploaded") + .HasColumnType("datetime2"); + + b.Property("DeleteKey") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("Downloads") + .HasColumnType("int"); + + b.Property("ExpireDate") + .HasColumnType("datetime2"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("IV") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("Key") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("KeySize") + .HasColumnType("int"); + + b.Property("MaxDownloads") + .HasColumnType("int"); + + b.Property("Takedown_TakedownId") + .HasColumnType("int"); + + b.Property("Url") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("UploadId"); + + b.HasIndex("Takedown_TakedownId"); + + b.HasIndex("Url"); + + b.HasIndex("UserId"); + + b.ToTable("Uploads"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.Feature", b => + { + b.Property("FeatureId") + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("FeatureId"); + + b.ToTable("Features"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b => + { + b.Property("InviteCodeId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Active") + .HasColumnType("bit"); + + b.Property("ClaimedUserId") + .HasColumnType("int"); + + b.Property("Code") + .HasColumnType("nvarchar(max)") + .HasAnnotation("CaseSensitive", true); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.HasKey("InviteCodeId"); + + b.HasIndex("ClaimedUserId") + .IsUnique() + .HasFilter("[ClaimedUserId] IS NOT NULL"); + + b.HasIndex("OwnerId"); + + b.ToTable("InviteCodes"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Username") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b => + { + b.Property("UserFeatureId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("FeatureId") + .HasColumnType("nvarchar(450)"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("UserFeatureId"); + + b.HasIndex("FeatureId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFeatures"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.Property("VaultId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateCreated") + .HasColumnType("datetime2"); + + b.Property("DateEdited") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("Views") + .HasColumnType("int"); + + b.HasKey("VaultId"); + + b.HasIndex("Url"); + + b.HasIndex("UserId"); + + b.ToTable("Vaults"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b => + { + b.Property("VaultItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Index") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("VaultId") + .HasColumnType("int"); + + b.HasKey("VaultItemId"); + + b.HasIndex("VaultId"); + + b.ToTable("VaultItems"); + + b.HasDiscriminator("Discriminator").HasValue("VaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b => + { + b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem"); + + b.Property("PasteId") + .HasColumnType("int"); + + b.HasIndex("PasteId"); + + b.HasDiscriminator().HasValue("PasteVaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b => + { + b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem"); + + b.Property("UploadId") + .HasColumnType("int"); + + b.HasIndex("UploadId"); + + b.HasDiscriminator().HasValue("UploadVaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Billing.Models.Customer", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithOne("BillingCustomer") + .HasForeignKey("Teknik.Areas.Billing.Models.Customer", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.HasOne("Teknik.Areas.Blog.Models.Blog", "Blog") + .WithMany("BlogPosts") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b => + { + b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost") + .WithMany("Comments") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("BlogPost"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b => + { + b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost") + .WithMany("Tags") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BlogPost"); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Pastes") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Comments") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Podcast"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Files") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Podcast"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Tags") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Podcast"); + }); + + modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("ShortenedUrls") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.HasOne("Teknik.Areas.Stats.Models.Takedown", null) + .WithMany("Attachments") + .HasForeignKey("Takedown_TakedownId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Uploads") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "ClaimedUser") + .WithOne("ClaimedInviteCode") + .HasForeignKey("Teknik.Areas.Users.Models.InviteCode", "ClaimedUserId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "Owner") + .WithMany("OwnedInviteCodes") + .HasForeignKey("OwnerId"); + + b.Navigation("ClaimedUser"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.OwnsOne("Teknik.Areas.Users.Models.BlogSettings", "BlogSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Description") + .HasColumnType("nvarchar(max)") + .HasColumnName("Description"); + + b1.Property("Title") + .HasColumnType("nvarchar(max)") + .HasColumnName("Title"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.OwnsOne("Teknik.Areas.Users.Models.UploadSettings", "UploadSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Encrypt") + .HasColumnType("bit") + .HasColumnName("Encrypt"); + + b1.Property("ExpirationLength") + .HasColumnType("int") + .HasColumnName("ExpirationLength"); + + b1.Property("ExpirationUnit") + .HasColumnType("int") + .HasColumnName("ExpirationUnit"); + + b1.Property("MaxUploadFileSize") + .HasColumnType("bigint") + .HasColumnName("MaxUploadFileSize"); + + b1.Property("MaxUploadStorage") + .HasColumnType("bigint") + .HasColumnName("MaxUploadStorage"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.OwnsOne("Teknik.Areas.Users.Models.UserSettings", "UserSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("About") + .HasColumnType("nvarchar(max)") + .HasColumnName("About"); + + b1.Property("Quote") + .HasColumnType("nvarchar(max)") + .HasColumnName("Quote"); + + b1.Property("Website") + .HasColumnType("nvarchar(max)") + .HasColumnName("Website"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("BlogSettings"); + + b.Navigation("UploadSettings"); + + b.Navigation("UserSettings"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b => + { + b.HasOne("Teknik.Areas.Users.Models.Feature", "Feature") + .WithMany() + .HasForeignKey("FeatureId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Features") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Feature"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Vaults") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b => + { + b.HasOne("Teknik.Areas.Vault.Models.Vault", "Vault") + .WithMany("VaultItems") + .HasForeignKey("VaultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Vault"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b => + { + b.HasOne("Teknik.Areas.Paste.Models.Paste", "Paste") + .WithMany("PasteVaultItems") + .HasForeignKey("PasteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Paste"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b => + { + b.HasOne("Teknik.Areas.Upload.Models.Upload", "Upload") + .WithMany("UploadVaultItems") + .HasForeignKey("UploadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Upload"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.Navigation("BlogPosts"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.Navigation("Comments"); + + b.Navigation("Tags"); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.Navigation("PasteVaultItems"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.Podcast", b => + { + b.Navigation("Comments"); + + b.Navigation("Files"); + + b.Navigation("Tags"); + }); + + modelBuilder.Entity("Teknik.Areas.Stats.Models.Takedown", b => + { + b.Navigation("Attachments"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.Navigation("UploadVaultItems"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.Navigation("BillingCustomer"); + + b.Navigation("ClaimedInviteCode"); + + b.Navigation("Features"); + + b.Navigation("OwnedInviteCodes"); + + b.Navigation("Pastes"); + + b.Navigation("ShortenedUrls"); + + b.Navigation("Uploads"); + + b.Navigation("Vaults"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.Navigation("VaultItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Teknik/Data/Migrations/20220521053504_UrlIndex.cs b/Teknik/Data/Migrations/20220521053504_UrlIndex.cs new file mode 100644 index 0000000..fe59bc6 --- /dev/null +++ b/Teknik/Data/Migrations/20220521053504_UrlIndex.cs @@ -0,0 +1,49 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Teknik.Data.Migrations +{ + public partial class UrlIndex : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_Vaults_Url", + table: "Vaults", + column: "Url"); + + migrationBuilder.CreateIndex( + name: "IX_Uploads_Url", + table: "Uploads", + column: "Url"); + + migrationBuilder.CreateIndex( + name: "IX_ShortenedUrls_ShortUrl", + table: "ShortenedUrls", + column: "ShortUrl"); + + migrationBuilder.CreateIndex( + name: "IX_Pastes_Url", + table: "Pastes", + column: "Url"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Vaults_Url", + table: "Vaults"); + + migrationBuilder.DropIndex( + name: "IX_Uploads_Url", + table: "Uploads"); + + migrationBuilder.DropIndex( + name: "IX_ShortenedUrls_ShortUrl", + table: "ShortenedUrls"); + + migrationBuilder.DropIndex( + name: "IX_Pastes_Url", + table: "Pastes"); + } + } +} diff --git a/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs b/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs index 1f88cb4..de6de80 100644 --- a/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs +++ b/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs @@ -227,7 +227,8 @@ namespace Teknik.Data.Migrations .HasColumnType("nvarchar(max)"); b.Property("Url") - .HasColumnType("nvarchar(max)") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") .HasAnnotation("CaseSensitive", true); b.Property("UserId") @@ -238,6 +239,8 @@ namespace Teknik.Data.Migrations b.HasKey("PasteId"); + b.HasIndex("Url"); + b.HasIndex("UserId"); b.ToTable("Pastes"); @@ -376,7 +379,8 @@ namespace Teknik.Data.Migrations .HasColumnType("nvarchar(max)"); b.Property("ShortUrl") - .HasColumnType("nvarchar(max)") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") .HasAnnotation("CaseSensitive", true); b.Property("UserId") @@ -387,6 +391,8 @@ namespace Teknik.Data.Migrations b.HasKey("ShortenedUrlId"); + b.HasIndex("ShortUrl"); + b.HasIndex("UserId"); b.ToTable("ShortenedUrls"); @@ -422,30 +428,6 @@ namespace Teknik.Data.Migrations b.ToTable("Takedowns"); }); - modelBuilder.Entity("Teknik.Areas.Stats.Models.Transaction", b => - { - b.Property("TransactionId") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("Amount") - .HasColumnType("decimal(19,5)"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("DateSent") - .HasColumnType("datetime2"); - - b.Property("Reason") - .HasColumnType("nvarchar(max)"); - - b.HasKey("TransactionId"); - - b.ToTable("Transactions"); - }); - modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => { b.Property("UploadId") @@ -497,7 +479,8 @@ namespace Teknik.Data.Migrations .HasColumnType("int"); b.Property("Url") - .HasColumnType("nvarchar(max)") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") .HasAnnotation("CaseSensitive", true); b.Property("UserId") @@ -507,6 +490,8 @@ namespace Teknik.Data.Migrations b.HasIndex("Takedown_TakedownId"); + b.HasIndex("Url"); + b.HasIndex("UserId"); b.ToTable("Uploads"); @@ -619,7 +604,9 @@ namespace Teknik.Data.Migrations .HasColumnType("nvarchar(max)"); b.Property("Url") - .HasColumnType("nvarchar(max)"); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)") + .HasAnnotation("CaseSensitive", true); b.Property("UserId") .HasColumnType("int"); @@ -629,6 +616,8 @@ namespace Teknik.Data.Migrations b.HasKey("VaultId"); + b.HasIndex("Url"); + b.HasIndex("UserId"); b.ToTable("Vaults");