From bee733b3daae9765bc2ef96fb2fd972499e32305 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 28 Apr 2024 20:15:56 +0200 Subject: [PATCH] [backend/database] Rename DataProtectionKeys table to data_protection_keys for consistency --- .../Core/Database/DatabaseContext.cs | 2 + .../DatabaseContextModelSnapshot.cs | 2 +- ...428181455_RenameDataProtectionKeysTable.cs | 47 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240428181455_RenameDataProtectionKeysTable.cs diff --git a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs index 35dbc323..d79403fd 100644 --- a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs +++ b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs @@ -1180,6 +1180,8 @@ public class DatabaseContext(DbContextOptions options) entity.HasOne().WithMany().HasForeignKey(d => d.WorkerId).OnDelete(DeleteBehavior.SetNull); }); + modelBuilder.Entity().ToTable("data_protection_keys"); + modelBuilder.ApplyConfigurationsFromAssembly(typeof(DatabaseContext).Assembly); } diff --git a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs index 66016aae..862c0a5e 100644 --- a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs +++ b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs @@ -4859,7 +4859,7 @@ namespace Iceshrimp.Backend.Core.Database.Migrations b.HasKey("Id"); - b.ToTable("DataProtectionKeys"); + b.ToTable("data_protection_keys", (string)null); }); modelBuilder.Entity("Iceshrimp.Backend.Core.Database.Tables.AbuseUserReport", b => diff --git a/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240428181455_RenameDataProtectionKeysTable.cs b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240428181455_RenameDataProtectionKeysTable.cs new file mode 100644 index 00000000..010fe971 --- /dev/null +++ b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240428181455_RenameDataProtectionKeysTable.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Infrastructure; + +#nullable disable + +namespace Iceshrimp.Backend.Core.Database.Migrations +{ + /// + [DbContext(typeof(DatabaseContext))] + [Migration("20240428181455_RenameDataProtectionKeysTable")] + public partial class RenameDataProtectionKeysTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_DataProtectionKeys", + table: "DataProtectionKeys"); + + migrationBuilder.RenameTable( + name: "DataProtectionKeys", + newName: "data_protection_keys"); + + migrationBuilder.AddPrimaryKey( + name: "PK_data_protection_keys", + table: "data_protection_keys", + column: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_data_protection_keys", + table: "data_protection_keys"); + + migrationBuilder.RenameTable( + name: "data_protection_keys", + newName: "DataProtectionKeys"); + + migrationBuilder.AddPrimaryKey( + name: "PK_DataProtectionKeys", + table: "DataProtectionKeys", + column: "Id"); + } + } +}