[backend/database] Remove unique constraints for drive file access keys

We are now doing proper deduplication so these are not useful anymore.
This commit is contained in:
Laura Hausmann 2024-02-13 01:09:00 +01:00
parent 5a7ef95ff4
commit d847c0d7d6
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
4 changed files with 6041 additions and 9 deletions

View file

@ -0,0 +1,75 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Iceshrimp.Backend.Core.Database.Migrations
{
/// <inheritdoc />
public partial class RemoveDriveFileUniqueConstraints : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_drive_file_accessKey",
table: "drive_file");
migrationBuilder.DropIndex(
name: "IX_drive_file_thumbnailAccessKey",
table: "drive_file");
migrationBuilder.DropIndex(
name: "IX_drive_file_webpublicAccessKey",
table: "drive_file");
migrationBuilder.CreateIndex(
name: "IX_drive_file_accessKey",
table: "drive_file",
column: "accessKey");
migrationBuilder.CreateIndex(
name: "IX_drive_file_thumbnailAccessKey",
table: "drive_file",
column: "thumbnailAccessKey");
migrationBuilder.CreateIndex(
name: "IX_drive_file_webpublicAccessKey",
table: "drive_file",
column: "webpublicAccessKey");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_drive_file_accessKey",
table: "drive_file");
migrationBuilder.DropIndex(
name: "IX_drive_file_thumbnailAccessKey",
table: "drive_file");
migrationBuilder.DropIndex(
name: "IX_drive_file_webpublicAccessKey",
table: "drive_file");
migrationBuilder.CreateIndex(
name: "IX_drive_file_accessKey",
table: "drive_file",
column: "accessKey",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_drive_file_thumbnailAccessKey",
table: "drive_file",
column: "thumbnailAccessKey",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_drive_file_webpublicAccessKey",
table: "drive_file",
column: "webpublicAccessKey",
unique: true);
}
}
}

View file

@ -991,8 +991,7 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("AccessKey") b.HasIndex("AccessKey");
.IsUnique();
b.HasIndex("CreatedAt"); b.HasIndex("CreatedAt");
@ -1004,8 +1003,7 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
b.HasIndex("Sha256"); b.HasIndex("Sha256");
b.HasIndex("ThumbnailAccessKey") b.HasIndex("ThumbnailAccessKey");
.IsUnique();
b.HasIndex("Type"); b.HasIndex("Type");
@ -1015,8 +1013,7 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
b.HasIndex("UserId"); b.HasIndex("UserId");
b.HasIndex("WebpublicAccessKey") b.HasIndex("WebpublicAccessKey");
.IsUnique();
b.HasIndex("UserId", "FolderId", "Id"); b.HasIndex("UserId", "FolderId", "Id");

View file

@ -15,11 +15,11 @@ namespace Iceshrimp.Backend.Core.Database.Tables;
[Index("Type")] [Index("Type")]
[Index("IsSensitive")] [Index("IsSensitive")]
[Index("FolderId")] [Index("FolderId")]
[Index("WebpublicAccessKey", IsUnique = true)] [Index("WebpublicAccessKey")]
[Index("CreatedAt")] [Index("CreatedAt")]
[Index("AccessKey", IsUnique = true)] [Index("AccessKey")]
[Index("Uri")] [Index("Uri")]
[Index("ThumbnailAccessKey", IsUnique = true)] [Index("ThumbnailAccessKey")]
public class DriveFile : IEntity { public class DriveFile : IEntity {
/// <summary> /// <summary>
/// The created date of the DriveFile. /// The created date of the DriveFile.