1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Add index for URls

This commit is contained in:
Uncled1023 2022-05-20 22:49:17 -07:00
parent d5e885fad5
commit 169ec3d919
9 changed files with 2294 additions and 33 deletions

View File

@ -1,5 +1,7 @@
using System; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -9,6 +11,7 @@ using Teknik.Models;
namespace Teknik.Areas.Paste.Models namespace Teknik.Areas.Paste.Models
{ {
[Index(nameof(Url))]
public class Paste public class Paste
{ {
public int PasteId { get; set; } public int PasteId { get; set; }
@ -23,6 +26,7 @@ namespace Teknik.Areas.Paste.Models
public DateTime DateEdited { get; set; } public DateTime DateEdited { get; set; }
[MaxLength(250)]
[CaseSensitive] [CaseSensitive]
public string Url { get; set; } public string Url { get; set; }

View File

@ -1,5 +1,7 @@
using System; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using Teknik.Areas.Users.Models; using Teknik.Areas.Users.Models;
@ -7,6 +9,7 @@ using Teknik.Attributes;
namespace Teknik.Areas.Shortener.Models namespace Teknik.Areas.Shortener.Models
{ {
[Index(nameof(ShortUrl))]
public class ShortenedUrl public class ShortenedUrl
{ {
public int ShortenedUrlId { get; set; } public int ShortenedUrlId { get; set; }
@ -15,6 +18,7 @@ namespace Teknik.Areas.Shortener.Models
public virtual User User { get; set; } public virtual User User { get; set; }
[MaxLength(250)]
[CaseSensitive] [CaseSensitive]
public string ShortUrl { get; set; } public string ShortUrl { get; set; }

View File

@ -1,5 +1,7 @@
using System; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using Teknik.Areas.Users.Models; using Teknik.Areas.Users.Models;
@ -7,6 +9,7 @@ using Teknik.Attributes;
namespace Teknik.Areas.Upload.Models namespace Teknik.Areas.Upload.Models
{ {
[Index(nameof(Url))]
public class Upload public class Upload
{ {
public int UploadId { get; set; } public int UploadId { get; set; }
@ -19,6 +22,7 @@ namespace Teknik.Areas.Upload.Models
public DateTime DateUploaded { get; set; } public DateTime DateUploaded { get; set; }
[MaxLength(250)]
[CaseSensitive] [CaseSensitive]
public string Url { get; set; } public string Url { get; set; }

View File

@ -1,10 +1,14 @@
using System; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using Teknik.Attributes;
namespace Teknik.Areas.Vault.Models namespace Teknik.Areas.Vault.Models
{ {
[Index(nameof(Url))]
public class Vault public class Vault
{ {
public int VaultId { get; set; } public int VaultId { get; set; }
@ -13,6 +17,8 @@ namespace Teknik.Areas.Vault.Models
public virtual Users.Models.User User { get; set; } public virtual Users.Models.User User { get; set; }
[MaxLength(250)]
[CaseSensitive]
public string Url { get; set; } public string Url { get; set; }
public string Title { get; set; } public string Title { get; set; }

File diff suppressed because it is too large Load Diff

View File

@ -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<string>(
name: "Url",
table: "Vaults",
type: "nvarchar(250)",
maxLength: 250,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Url",
table: "Uploads",
type: "nvarchar(250)",
maxLength: 250,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ShortUrl",
table: "ShortenedUrls",
type: "nvarchar(250)",
maxLength: 250,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
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<string>(
name: "Url",
table: "Vaults",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(250)",
oldMaxLength: 250,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Url",
table: "Uploads",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(250)",
oldMaxLength: 250,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ShortUrl",
table: "ShortenedUrls",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(250)",
oldMaxLength: 250,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Amount = table.Column<decimal>(type: "decimal(19,5)", nullable: false),
Currency = table.Column<int>(type: "int", nullable: false),
DateSent = table.Column<DateTime>(type: "datetime2", nullable: false),
Reason = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Transactions", x => x.TransactionId);
});
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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");
}
}
}

View File

@ -227,7 +227,8 @@ namespace Teknik.Data.Migrations
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("nvarchar(max)") .HasMaxLength(250)
.HasColumnType("nvarchar(250)")
.HasAnnotation("CaseSensitive", true); .HasAnnotation("CaseSensitive", true);
b.Property<int?>("UserId") b.Property<int?>("UserId")
@ -238,6 +239,8 @@ namespace Teknik.Data.Migrations
b.HasKey("PasteId"); b.HasKey("PasteId");
b.HasIndex("Url");
b.HasIndex("UserId"); b.HasIndex("UserId");
b.ToTable("Pastes"); b.ToTable("Pastes");
@ -376,7 +379,8 @@ namespace Teknik.Data.Migrations
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("ShortUrl") b.Property<string>("ShortUrl")
.HasColumnType("nvarchar(max)") .HasMaxLength(250)
.HasColumnType("nvarchar(250)")
.HasAnnotation("CaseSensitive", true); .HasAnnotation("CaseSensitive", true);
b.Property<int?>("UserId") b.Property<int?>("UserId")
@ -387,6 +391,8 @@ namespace Teknik.Data.Migrations
b.HasKey("ShortenedUrlId"); b.HasKey("ShortenedUrlId");
b.HasIndex("ShortUrl");
b.HasIndex("UserId"); b.HasIndex("UserId");
b.ToTable("ShortenedUrls"); b.ToTable("ShortenedUrls");
@ -422,30 +428,6 @@ namespace Teknik.Data.Migrations
b.ToTable("Takedowns"); b.ToTable("Takedowns");
}); });
modelBuilder.Entity("Teknik.Areas.Stats.Models.Transaction", b =>
{
b.Property<int>("TransactionId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<decimal>("Amount")
.HasColumnType("decimal(19,5)");
b.Property<int>("Currency")
.HasColumnType("int");
b.Property<DateTime>("DateSent")
.HasColumnType("datetime2");
b.Property<string>("Reason")
.HasColumnType("nvarchar(max)");
b.HasKey("TransactionId");
b.ToTable("Transactions");
});
modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b =>
{ {
b.Property<int>("UploadId") b.Property<int>("UploadId")
@ -497,7 +479,8 @@ namespace Teknik.Data.Migrations
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("nvarchar(max)") .HasMaxLength(250)
.HasColumnType("nvarchar(250)")
.HasAnnotation("CaseSensitive", true); .HasAnnotation("CaseSensitive", true);
b.Property<int?>("UserId") b.Property<int?>("UserId")
@ -507,6 +490,8 @@ namespace Teknik.Data.Migrations
b.HasIndex("Takedown_TakedownId"); b.HasIndex("Takedown_TakedownId");
b.HasIndex("Url");
b.HasIndex("UserId"); b.HasIndex("UserId");
b.ToTable("Uploads"); b.ToTable("Uploads");
@ -619,7 +604,9 @@ namespace Teknik.Data.Migrations
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("nvarchar(max)"); .HasMaxLength(250)
.HasColumnType("nvarchar(250)")
.HasAnnotation("CaseSensitive", true);
b.Property<int?>("UserId") b.Property<int?>("UserId")
.HasColumnType("int"); .HasColumnType("int");
@ -629,6 +616,8 @@ namespace Teknik.Data.Migrations
b.HasKey("VaultId"); b.HasKey("VaultId");
b.HasIndex("Url");
b.HasIndex("UserId"); b.HasIndex("UserId");
b.ToTable("Vaults"); b.ToTable("Vaults");