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:
parent
d5e885fad5
commit
169ec3d919
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
|
1042
Teknik/Data/Migrations/20220521053202_MaxUrlLength.Designer.cs
generated
Normal file
1042
Teknik/Data/Migrations/20220521053202_MaxUrlLength.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
113
Teknik/Data/Migrations/20220521053202_MaxUrlLength.cs
Normal file
113
Teknik/Data/Migrations/20220521053202_MaxUrlLength.cs
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
1050
Teknik/Data/Migrations/20220521053504_UrlIndex.Designer.cs
generated
Normal file
1050
Teknik/Data/Migrations/20220521053504_UrlIndex.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
49
Teknik/Data/Migrations/20220521053504_UrlIndex.cs
Normal file
49
Teknik/Data/Migrations/20220521053504_UrlIndex.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
@ -227,7 +227,8 @@ namespace Teknik.Data.Migrations
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.HasColumnType("nvarchar(max)")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("nvarchar(250)")
|
||||
.HasAnnotation("CaseSensitive", true);
|
||||
|
||||
b.Property<int?>("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<string>("ShortUrl")
|
||||
.HasColumnType("nvarchar(max)")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("nvarchar(250)")
|
||||
.HasAnnotation("CaseSensitive", true);
|
||||
|
||||
b.Property<int?>("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<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 =>
|
||||
{
|
||||
b.Property<int>("UploadId")
|
||||
@ -497,7 +479,8 @@ namespace Teknik.Data.Migrations
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.HasColumnType("nvarchar(max)")
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("nvarchar(250)")
|
||||
.HasAnnotation("CaseSensitive", true);
|
||||
|
||||
b.Property<int?>("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<string>("Url")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasMaxLength(250)
|
||||
.HasColumnType("nvarchar(250)")
|
||||
.HasAnnotation("CaseSensitive", true);
|
||||
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("int");
|
||||
@ -629,6 +616,8 @@ namespace Teknik.Data.Migrations
|
||||
|
||||
b.HasKey("VaultId");
|
||||
|
||||
b.HasIndex("Url");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Vaults");
|
||||
|
Loading…
Reference in New Issue
Block a user